What are some useful SQL statements that should be known by all developers who may touch the Back en
Posted
by Jian Lin
on Stack Overflow
See other posts from Stack Overflow
or by Jian Lin
Published on 2010-04-23T19:36:33Z
Indexed on
2010/04/23
19:53 UTC
Read the original article
Hit count: 259
What are some useful SQL statements that should be known by all developers who may touch the Back end side of the project?
(Update: just like in algorithm, we know there are sorting problems, shuffling problems, and we know some solutions to them. This question is aiming at the same thing).
For example, ones I can think of are:
Get a list of Employees and their boss. Or one with the employee's salary greater than the boss. (Self-join)
Get a list of the most popular Classes registered by students, from the greatest number to the smallest. (Count, group by, order by)
Get a list of Classes that are not registered by any students. (Outer join and check whether the match is NULL, or by Get from Classes table, all ClassIDs which are NOT IN (a subquery to get all ClassIDs from the Registrations table))
Are there some SQL statements that should be under the sleeve of all developers that might touch back end data?
© Stack Overflow or respective owner