Wednesday, January 6, 2021

Priority of order in Syntax for where, group by, having, order by

There are particular sequence in sql syntax as per follows: 


SELECT ...

WHERE..

GROUP BY..

HAVING

ORDER BY...DESC

Example 

SELECT strftime('%H',timestamp) as Hours , round(AVG(score),0)COUNT(*) as Count_of_Stories FROM hacker_news 
where timestamp is NOT NULL
GROUP BY 1 
ORDER BY 1 

No comments:

Post a Comment