SELECT ROWNUM SLNO, QRY.* FROM (SELECT TRADE_PK,TRADE_ID, TRADE_NAME,SELFLAG
FROM (SELECT DISTINCT TMT.TRADE_MST_PK TRADE_PK,
TMT.TRADE_CODE TRADE_ID,
TMT.TRADE_NAME TRADE_NAME,
'1' SELFLAG
FROM TRADE_MST_TBL TMT
WHERE TMT.TRADE_MST_PK IN (222, 226 , 227, 224, 225)
UNION
SELECT DISTINCT TMT.TRADE_MST_PK TRADE_PK,
TMT.TRADE_CODE TRADE_ID,
TMT.TRADE_NAME TRADE_NAME,
'' SELFLAG
FROM TRADE_MST_TBL TMT
WHERE TMT.TRADE_MST_PK NOT IN (222, 226 , 227, 224, 225))
ORDER BY SELFLAG ASC)QRY
FROM (SELECT DISTINCT TMT.TRADE_MST_PK TRADE_PK,
TMT.TRADE_CODE TRADE_ID,
TMT.TRADE_NAME TRADE_NAME,
'1' SELFLAG
FROM TRADE_MST_TBL TMT
WHERE TMT.TRADE_MST_PK IN (222, 226 , 227, 224, 225)
UNION
SELECT DISTINCT TMT.TRADE_MST_PK TRADE_PK,
TMT.TRADE_CODE TRADE_ID,
TMT.TRADE_NAME TRADE_NAME,
'' SELFLAG
FROM TRADE_MST_TBL TMT
WHERE TMT.TRADE_MST_PK NOT IN (222, 226 , 227, 224, 225))
ORDER BY SELFLAG ASC)QRY
No comments:
Post a Comment