Subject | Order By Not Working Using "WITH" Clause |
---|---|
Author | Vishal Tiwari |
Post date | 2015-07-03T12:15:31Z |
Hi All,
I have below SQL, which is concatenating the ShortCode column data, but without ordering as per the ORDER_NUMBER column in ABC table in "WITH" clause.
Please help.
With TBL_SHORT_CODE (SHORT_CODE, FK_KEY) As
(
SELECT Distinct(XYZ.SHORT_CODE) As SHORT_CODE, ABC.FK_KEY
From ABC Join XYZ On ABC.PK_KEY = XYZ.FK_KEY
where XYZ.FK_KEY = '{009DA0F8-51EE-4207-86A6-7E18F96B983A}' And ABC.STATUS_CODE = 1
Order By ABC.ORDER_NUMBER
)
SELECT LIST(Distinct(TBL_SHORT_CODE.SHORT_CODE), '' ), ABC.FK_BOM
From ABC
Join XYZ ON ABC.FK_KEY = XYZ.PK_KEY
Join TBL_SHORT_CODE On TBL_SHORT_CODE.FK_KEY = ABC.FK_KEY
where ABC.FK_BOM = '{009DA0F8-51EE-4207-86A6-7E18F96B983A}' And ABC.STATUS_CODE = 1
Group By ABC.FK_BOM
Thanks In Advance.
With Best Regards.
Vishal