Click here to Skip to main content
15,922,696 members

Comments by Goutam Patra (Top 83 by date)

Goutam Patra 24-Jan-11 8:08am View    
Simple,
CREATE TABLE SALARY (EMPCODE VARCHAR(10), SALARY MONEY)
INSERT INTO SALARY VALUES('A1', 15000)
INSERT INTO SALARY VALUES('A2', 20000)
INSERT INTO SALARY VALUES('A3', 25000)
INSERT INTO SALARY VALUES('A4', 30000)
INSERT INTO SALARY VALUES('A5', 35000)

SELECT * FROM (
SELECT EMPCODE, SALARY,
RANK() OVER (ORDER BY SALARY DESC) AS MYRANK
FROM SALARY
) AS A
WHERE MYRANK = 4

This will fetch 4th highest salary.
wont that. Please reply if it does.
Goutam Patra 24-Jan-11 7:58am View    
Like
SELECT * FROM (
SELECT CODE, AMOUNT AS AMT,
RANK() OVER (PARTITION BY CODE ORDER BY AMOUNT) AS MYRANK
FROM CBJDETAIL
) AS A
WHERE MYRANK = 4

Goutam Patra 27-Dec-10 5:38am View    
I didnt downvoted you.
Goutam Patra 27-Dec-10 5:37am View    
Deleted
But WHERE Name like '%@Name%' will search names stared with [%@Name%], not the value inside @Name var. Will it? just asking.
Goutam Patra 27-Dec-10 5:24am View    
Check the updated answer