Frage

SELECT COLUMN FROM TABLE WHERE ACTION='ABC' AND ROWNUM<=1;

I have a doubt in mssql. I need to migrate the above oracle query into mssql. I'm struggling with ROWNUM.

War es hilfreich?

Lösung

SELECT TOP 1 COLUMN 
FROM TABLE 
WHERE ACTION='ABC'

You may need to use Order By too, which is...

SELECT TOP 1 COLUMN 
FROM TABLE 
WHERE ACTION='ABC' 
Order by columnnane asc/desc 

note: if you don't specify the direction (ASC / DESC) after the Order By, the default is ASC.

Andere Tipps

Try this

SELECT Top 10 * FROM TABLE WHERE ACTION='ABC' 
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top