Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
sramlaxman
Starting Member
1 Post |
Posted - 2011-04-08 : 16:20:41
|
| I am Working with business objects Reporting tool. I have problem understanding the SQL generated by the tool. the SQL is as followsSELECT Reporting.dbo.APPLICATION_IDFROM Reporting.dbo.INSTANCEWHERE Reporting.dbo.APPLICATION_ID IN ( SELECT View__1.Column__1 FROM ( SELECT Reporting.dbo.INSTANCE.APPLICATION_ID AS Column__1, RANK() OVER( ORDER BY Reporting.dbo.INSTANCE.TIME_SUM DESC) AS Rk__1 FROM Reporting.dbo.INSTANCE ) View__1 WHERE View__1.Rk__1 <= 10 )As specified in last line of the SQL I should get top ten results of the application. I am only getting four applications when I run the SQL against the database and more over the ranking is also not correct with some top applications replaced by lower ones. Please verify the SQL if it is the correct to generate top ten application ID's based on Active time (used in rank function).ThanksRam |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2011-04-08 : 16:44:48
|
[code]-- Original suggestionSELECT Reporting.dbo.APPLICATION_IDFROM Reporting.dbo.INSTANCEWHERE Reporting.dbo.APPLICATION_ID IN ( SELECT View__1.Column__1 FROM ( SELECT Reporting.dbo.INSTANCE.APPLICATION_ID AS Column__1, RANK() OVER( ORDER BY Reporting.dbo.INSTANCE.TIME_SUM DESC) AS Rk__1 FROM Reporting.dbo.INSTANCE ) View__1 WHERE View__1.Rk__1 <= 10 )-- PesoSELECT APPLICATION_IDFROM ( SELECT APPLICATION_ID, RANK() OVER (ORDER BY TIME_SUM DESC) AS Rnk FROM Reporting.dbo.INSTANCE ) AS dWHERE Rnk <= 10[/code] N 56°04'39.26"E 12°55'05.63" |
 |
|
|
|
|
|