Sql Flashcards

1
Q

How do you eliminate duplicates in sql

A

Select distinct

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How do you name the column you are returning from database

A

As

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How do you select what table you are querying in the database

A

Select* if searching the entire database
Select from to specify a table

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

String length

A

Len(column)
Length(column)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How do you add conditions

A

Where

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How do you use the substring function

A

Substring(column,position of first character you want to return, total length of the substring)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Dml

A

Data manipulation language

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Cast()

A

Can be used to convert anything from one data type to another.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Coalesce

A

Coalesce(columna,columnb) if no value in a it returns value in b

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How do you change data types?

A

Cast
Cast as [data type]
From table

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How do you avoid failed returns when casting (error)

A

Safe_cast: returns null value where the errors are. This allows the action to be completed without failing the entire command.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What data types are ther

A

Int
String
Datetime
Many more

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is unix_date

A

UNIX_DATE returns the number of days that have passed since January 1, 1970 and is used to compare and work with dates across multiple time zones. You will likely use CAST most often.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Concat_ws

A

With separator adds character between

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Sql stores info In a 64 bit memory system

A

Int64

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Join

A

Part of a from clause. From table1, join table 2
On table 1. Column name
Signifies how tables are to be matched for the correct information to be combined from both.

17
Q

Types of joins

A

Right join, left join, inner, full outer

18
Q

Types of joins

A

Right join, left join, inner, full outer

19
Q

Inner join

A

Combines only info in both the tables

20
Q

Outer join

A

Combines only distinct info from both tables

21
Q

Left join

A

From
Table1.name
Table2.salesrep
Left join table 1
On customer.customerid = sales.customerid

22
Q

Left join

A

From
Table1.name
Table2.salesrep
Left join table 1
On customer.customerid = sales.customerid

23
Q

Full outer join

A

Returns all data from both tables paired up. Even if there are no pairs it will return the value with null

24
Q

Full outer join

A

Returns all data from both tables paired up. Even if there are no pairs it will return the value with null

25
Q

Foreign key

A

Links data in one table to data in another table. Same data type as the primary key it references

26
Q

IN operator

A

The IN operator allows you to specify multiple values in a where clause