Thursday, 10 November 2011

How to find the highest salary using SQL?

SELECT TOP 1 salary
FROM (
SELECT DISTINCT TOP 6 salary
FROM employee
ORDER BY salary DESC) a
ORDER BY salary

Thursday, 20 October 2011

SQL Processing order

The correct order of the Logical Query Processing Phases is as follows:
1. FROM
2. ON
3.OUTER
4.WHERE
5.GROUP BY
6.CUBE | ROLLUP
7.HAVING
8. SELECT
9. DISTINCT
10. TOP
11. ORDER BY