Subject | SELECT xx no of records |
---|---|
Author | Bhavbhuti Nathwani |
Post date | 2005-09-20T06:58:38Z |
Hi all
I have a list which I get by the SQL below. I want to get only say
the first 10, 20, etc. (as per user choice) records. Can I use a
clause something like TOP 10?
(The below SQL is copied from the Report Manager dataset so please
ignore the RM specific usage, but rest assured it works.)
SELECT 1 AS iOrder, tDaily.*
FROM tDaily
WHERE cMSF = 'G' AND cDirPattern = '2+2' AND dDt = :vp_dAsOfDt
UNION ALL
SELECT 2 AS iOrder, tDaily.*
FROM tDaily
WHERE cMSF = 'G' AND cDirPattern = '2+1' AND dDt = :vp_dAsOfDt
UNION ALL
SELECT 3 AS iOrder, tDaily.*
FROM tDaily
WHERE cMSF = 'G' AND cDirPattern = '3+1' AND dDt = :vp_dAsOfDt
UNION ALL
SELECT 4 AS iOrder, tDaily.*
FROM tDaily
WHERE cMSF = 'R' AND cDirPattern = '2+2' AND dDt = :vp_dAsOfDt
UNION ALL
SELECT 5 AS iOrder, tDaily.*
FROM tDaily
WHERE cMSF = 'R' AND cDirPattern = '2+1' AND dDt = :vp_dAsOfDt
UNION ALL
SELECT 6 AS iOrder, tDaily.*
FROM tDaily
WHERE cMSF = 'R' AND cDirPattern = '3+1' AND dDt = :vp_dAsOfDt
ORDER BY 1, 14 DESCENDING, 4, 5, 6
I have a list which I get by the SQL below. I want to get only say
the first 10, 20, etc. (as per user choice) records. Can I use a
clause something like TOP 10?
(The below SQL is copied from the Report Manager dataset so please
ignore the RM specific usage, but rest assured it works.)
SELECT 1 AS iOrder, tDaily.*
FROM tDaily
WHERE cMSF = 'G' AND cDirPattern = '2+2' AND dDt = :vp_dAsOfDt
UNION ALL
SELECT 2 AS iOrder, tDaily.*
FROM tDaily
WHERE cMSF = 'G' AND cDirPattern = '2+1' AND dDt = :vp_dAsOfDt
UNION ALL
SELECT 3 AS iOrder, tDaily.*
FROM tDaily
WHERE cMSF = 'G' AND cDirPattern = '3+1' AND dDt = :vp_dAsOfDt
UNION ALL
SELECT 4 AS iOrder, tDaily.*
FROM tDaily
WHERE cMSF = 'R' AND cDirPattern = '2+2' AND dDt = :vp_dAsOfDt
UNION ALL
SELECT 5 AS iOrder, tDaily.*
FROM tDaily
WHERE cMSF = 'R' AND cDirPattern = '2+1' AND dDt = :vp_dAsOfDt
UNION ALL
SELECT 6 AS iOrder, tDaily.*
FROM tDaily
WHERE cMSF = 'R' AND cDirPattern = '3+1' AND dDt = :vp_dAsOfDt
ORDER BY 1, 14 DESCENDING, 4, 5, 6