Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

syntax and formatting

Status
Not open for further replies.

db2HelpNeeded

Technical User
Sep 29, 2006
2
US
Hello,
looking for help in trying to run an inline view and then doing a select * off of that inline view. Something like this... but this gives me an error

SELECT * FROM (SELECT D.OID, A.DATEVALUEX AS SortValue
FROM DOCUMENTS D LEFT OUTER JOIN ATTRIBUTES A ON D.OID=A.DocumentOID AND A.AttributeDefOID=955
WHERE STATUSX=0 ORDER BY SortValue DESC)
fetch first 100 rows only
 
Code:
SELECT TEMP.KEY,TEMP.SortValue FROM (SELECT D.OID AS KEY, A.DATEVALUEX AS SortValue 
FROM DOCUMENTS D LEFT OUTER JOIN ATTRIBUTES A  ON D.OID=A.DocumentOID AND A.AttributeDefOID=955 
WHERE STATUSX=0 ORDER BY SortValue DESC) TEMP
fetch first 100 rows only

Why the inline view?


Ties Blom

 
wanted to make sure I get the sort done first and then take the first 100.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top