04pallav
9/13/2017 - 9:52 PM

SQL SYNTAX RULES/ ERRORS

SQL SYNTAX RULES/ ERRORS

1.
select sum(outcome_o.out) from outcome_o               cool 
with A as (select sum(outcome_o.out) from outcome_o)   NOTCOOL specify columnname

2. select sum(Income.inc) sumi, point ipoint, date idate from income group by point, date
# orginal column names should be used in group by and not the renamed ones

3. No need of else clasuse in case when then if nothing is there inside the 
clause  #just omit it

4. (select max(dist) from cities)  
 ####using brackets outside a single value query will convert it to a number
 #### no renaming here

5. Always check for ambiguous columns !!!!!!!!!!
6. two aggregation function at once wont work 
select max(count(trip_no))  from trip group by town_from, town_to  ####NOT COOL