SQL part 3 Flashcards

(25 cards)

1
Q

order by clause can order by

A

column names or column indices

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

t/f: with ORDER BY, you can use columns that have not been SELECT-ed

A

false

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

column aliases

A

allows columns to be renamed
- fine-tuned output
- often used to assign name to computed column

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

concat() operator + example

A

manipulates output data

select concat(x, y, z) as [new ouput]

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

MS access uses ___ instead of concat()

A

&

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

select distinct

A

removes duplicate values

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

aggregate functions are applied to

A

an attribute or an expression

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

examples of aggregate functions

A

min, max, sum, avg, count

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

t/f: aggregate functions cannot be used directly in a where clause

A

true

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

two options for COUNT

A
  • count(attribute) / count(expression): returns number of non-NULL values
  • count(*): returns total number of rows in resultset
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

COUNT(DISTINCT attribute) is supported in

A

MySQL, not MS Access

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

to replicate count(distinct), you can use

A

a subquery

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

a normal SELECT pulls data from ______, while SELECT based on a subquery pulls data from _______

A

DB table (relation), a resultset or compares data to a single SELECTed value

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

subquery format

A

select [columns]
from [tablename | (select…) ]
[where [criteria <=> (select…) ] ]

first (select) is table of values, second (select) is single value

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

group by

A

used with aggregate functions, combines similar records and into a single record

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

t/f: you must GROUP BY every SELECT-ed field that is not part of some aggregate function

17
Q

having clause

A

acts as a filter on the output of a group by clause. allows you to restrict results from aggregate fuctions

18
Q

action queries

A

insert, update, delete

19
Q

insert

A

insert a single record into a table

20
Q

insert format

A

insert into tableName
[ ( [Column1, Column2…] ) ]
values (value1 [, value2,…])

21
Q

update

A

change values within one or more rows in a table

22
Q

update format

A

update tablename
set column1=value [, column2=value2,…]
[where criteria (is true) ]

23
Q

delete

A

delete one or more rows from a table

24
Q

delete format

A

delete from table name
[where criteria (is true) ]

25
t/f: delete statement does not always delete entire rows
false. it always deletes entire rows