Group by Flashcards

1
Q

single row function

A

when we give 4 i/p we get 4 o/p (allow dupliactes)

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

Group BY

A

when we give 4 i/p we get 1 o/p ( don’t allow dupliactes). used to group the identical data together.

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

types of group by function

A

max , min , avg , count & sum

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

max in group by function

A

this will give 1 max value present in column

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

MAX example

A

select max (column) from table name

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

MIN in group by function

A

this will give 1 min value present in column

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

MIN example

A

select min (column) from table name

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

avg in group by function

A

this will give 1 average value present in column. We get decimal also.

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

How can we remove the decimal part from the average

A

round(avg(column))

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

avg eg

A

select round(avg(column)) from table_name

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

Count in group by function

A

count the number of records in the column. (Column (*))

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

will count group by function have null

A

yes

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

count (*)

A

where * return all column if no confition is specified over there.

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

sum in group by function

A

this will sum all the column values.

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

what us agregate column

A

if some action is performed on the column then we call it as agregated column

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

examples of agregates column

A

min, max , sum , count & avg

17
Q

What happens if we don’t run a grouping function on a column

A

If we don’t run a grouping function on a column, then we need to add that column in the ‘group by’ clause.

18
Q

should we mention aggregate column in group

A

no , we mention only non agrregate

19
Q

can we perform any action on aggregate column

A

yes , using having clause. It’s similar to the ‘where’ clause, but it works on aggregated data.

20
Q

to print non duplicates we use

A

distinct , group by

21
Q

amiguity

A

we get this when we have same column in both table

22
Q

how to solve amiguity

A

we can by specifying the table name before column name (tablename.columnname)

23
Q

can we have any short cut for writing the whole name of table multiple times

A

yes using aliases. Tablename a (a is aliases where it can be any thing)

24
Q

What is aliasing

A

Aliasing is a technique in SQL where we give a temporary name to a table or a column in a table. It is used to make column names more readable.

25
Q

How can we filter null values

A

‘is not null’ condition to filter null values.