Even if I don't use Distinct, i don't get expected result. 

     On Friday, 3 July 2015 7:17 PM, "Mark Rotteveel [email protected] 
[firebird-support]" <[email protected]> wrote:
   

     On Fri, 3 Jul 2015 12:15:31 +0000 (UTC), "Vishal Tiwari
[email protected] [firebird-support]"
<[email protected]> wrote:
> 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_KEYwhere XYZ.FK_KEY =
> '{009DA0F8-51EE-4207-86A6-7E18F96B983A}' And ABC.STATUS_CODE = 1Order By
> ABC.ORDER_NUMBER)
> 
> SELECT LIST(Distinct(TBL_SHORT_CODE.SHORT_CODE), '' ), ABC.FK_BOMFrom
> ABC Join XYZ ON ABC.FK_KEY = XYZ.PK_KEY Join TBL_SHORT_CODE On
> TBL_SHORT_CODE.FK_KEY = ABC.FK_KEYwhere ABC.FK_BOM =
> '{009DA0F8-51EE-4207-86A6-7E18F96B983A}' And ABC.STATUS_CODE = 1Group By
> ABC.FK_BOM

It doesn't work because of your use of distinct in LIST. This forces a
sort which overrides any previous order. I don't think there is a solution
to this problem except ineffecient and convoluted double querying.

Mark
  #yiv0671293864 #yiv0671293864 -- #yiv0671293864ygrp-mkp {border:1px solid 
#d8d8d8;font-family:Arial;margin:10px 0;padding:0 10px;}#yiv0671293864 
#yiv0671293864ygrp-mkp hr {border:1px solid #d8d8d8;}#yiv0671293864 
#yiv0671293864ygrp-mkp #yiv0671293864hd 
{color:#628c2a;font-size:85%;font-weight:700;line-height:122%;margin:10px 
0;}#yiv0671293864 #yiv0671293864ygrp-mkp #yiv0671293864ads 
{margin-bottom:10px;}#yiv0671293864 #yiv0671293864ygrp-mkp .yiv0671293864ad 
{padding:0 0;}#yiv0671293864 #yiv0671293864ygrp-mkp .yiv0671293864ad p 
{margin:0;}#yiv0671293864 #yiv0671293864ygrp-mkp .yiv0671293864ad a 
{color:#0000ff;text-decoration:none;}#yiv0671293864 #yiv0671293864ygrp-sponsor 
#yiv0671293864ygrp-lc {font-family:Arial;}#yiv0671293864 
#yiv0671293864ygrp-sponsor #yiv0671293864ygrp-lc #yiv0671293864hd {margin:10px 
0px;font-weight:700;font-size:78%;line-height:122%;}#yiv0671293864 
#yiv0671293864ygrp-sponsor #yiv0671293864ygrp-lc .yiv0671293864ad 
{margin-bottom:10px;padding:0 0;}#yiv0671293864 #yiv0671293864actions 
{font-family:Verdana;font-size:11px;padding:10px 0;}#yiv0671293864 
#yiv0671293864activity 
{background-color:#e0ecee;float:left;font-family:Verdana;font-size:10px;padding:10px;}#yiv0671293864
 #yiv0671293864activity span {font-weight:700;}#yiv0671293864 
#yiv0671293864activity span:first-child 
{text-transform:uppercase;}#yiv0671293864 #yiv0671293864activity span a 
{color:#5085b6;text-decoration:none;}#yiv0671293864 #yiv0671293864activity span 
span {color:#ff7900;}#yiv0671293864 #yiv0671293864activity span 
.yiv0671293864underline {text-decoration:underline;}#yiv0671293864 
.yiv0671293864attach 
{clear:both;display:table;font-family:Arial;font-size:12px;padding:10px 
0;width:400px;}#yiv0671293864 .yiv0671293864attach div a 
{text-decoration:none;}#yiv0671293864 .yiv0671293864attach img 
{border:none;padding-right:5px;}#yiv0671293864 .yiv0671293864attach label 
{display:block;margin-bottom:5px;}#yiv0671293864 .yiv0671293864attach label a 
{text-decoration:none;}#yiv0671293864 blockquote {margin:0 0 0 
4px;}#yiv0671293864 .yiv0671293864bold 
{font-family:Arial;font-size:13px;font-weight:700;}#yiv0671293864 
.yiv0671293864bold a {text-decoration:none;}#yiv0671293864 dd.yiv0671293864last 
p a {font-family:Verdana;font-weight:700;}#yiv0671293864 dd.yiv0671293864last p 
span {margin-right:10px;font-family:Verdana;font-weight:700;}#yiv0671293864 
dd.yiv0671293864last p span.yiv0671293864yshortcuts 
{margin-right:0;}#yiv0671293864 div.yiv0671293864attach-table div div a 
{text-decoration:none;}#yiv0671293864 div.yiv0671293864attach-table 
{width:400px;}#yiv0671293864 div.yiv0671293864file-title a, #yiv0671293864 
div.yiv0671293864file-title a:active, #yiv0671293864 
div.yiv0671293864file-title a:hover, #yiv0671293864 div.yiv0671293864file-title 
a:visited {text-decoration:none;}#yiv0671293864 div.yiv0671293864photo-title a, 
#yiv0671293864 div.yiv0671293864photo-title a:active, #yiv0671293864 
div.yiv0671293864photo-title a:hover, #yiv0671293864 
div.yiv0671293864photo-title a:visited {text-decoration:none;}#yiv0671293864 
div#yiv0671293864ygrp-mlmsg #yiv0671293864ygrp-msg p a 
span.yiv0671293864yshortcuts 
{font-family:Verdana;font-size:10px;font-weight:normal;}#yiv0671293864 
.yiv0671293864green {color:#628c2a;}#yiv0671293864 .yiv0671293864MsoNormal 
{margin:0 0 0 0;}#yiv0671293864 o {font-size:0;}#yiv0671293864 
#yiv0671293864photos div {float:left;width:72px;}#yiv0671293864 
#yiv0671293864photos div div {border:1px solid 
#666666;height:62px;overflow:hidden;width:62px;}#yiv0671293864 
#yiv0671293864photos div label 
{color:#666666;font-size:10px;overflow:hidden;text-align:center;white-space:nowrap;width:64px;}#yiv0671293864
 #yiv0671293864reco-category {font-size:77%;}#yiv0671293864 
#yiv0671293864reco-desc {font-size:77%;}#yiv0671293864 .yiv0671293864replbq 
{margin:4px;}#yiv0671293864 #yiv0671293864ygrp-actbar div a:first-child 
{margin-right:2px;padding-right:5px;}#yiv0671293864 #yiv0671293864ygrp-mlmsg 
{font-size:13px;font-family:Arial, helvetica, clean, sans-serif;}#yiv0671293864 
#yiv0671293864ygrp-mlmsg table {font-size:inherit;font:100%;}#yiv0671293864 
#yiv0671293864ygrp-mlmsg select, #yiv0671293864 input, #yiv0671293864 textarea 
{font:99% Arial, Helvetica, clean, sans-serif;}#yiv0671293864 
#yiv0671293864ygrp-mlmsg pre, #yiv0671293864 code {font:115% 
monospace;}#yiv0671293864 #yiv0671293864ygrp-mlmsg * 
{line-height:1.22em;}#yiv0671293864 #yiv0671293864ygrp-mlmsg #yiv0671293864logo 
{padding-bottom:10px;}#yiv0671293864 #yiv0671293864ygrp-msg p a 
{font-family:Verdana;}#yiv0671293864 #yiv0671293864ygrp-msg 
p#yiv0671293864attach-count span {color:#1E66AE;font-weight:700;}#yiv0671293864 
#yiv0671293864ygrp-reco #yiv0671293864reco-head 
{color:#ff7900;font-weight:700;}#yiv0671293864 #yiv0671293864ygrp-reco 
{margin-bottom:20px;padding:0px;}#yiv0671293864 #yiv0671293864ygrp-sponsor 
#yiv0671293864ov li a {font-size:130%;text-decoration:none;}#yiv0671293864 
#yiv0671293864ygrp-sponsor #yiv0671293864ov li 
{font-size:77%;list-style-type:square;padding:6px 0;}#yiv0671293864 
#yiv0671293864ygrp-sponsor #yiv0671293864ov ul {margin:0;padding:0 0 0 
8px;}#yiv0671293864 #yiv0671293864ygrp-text 
{font-family:Georgia;}#yiv0671293864 #yiv0671293864ygrp-text p {margin:0 0 1em 
0;}#yiv0671293864 #yiv0671293864ygrp-text tt {font-size:120%;}#yiv0671293864 
#yiv0671293864ygrp-vital ul li:last-child {border-right:none 
!important;}#yiv0671293864 

  

Reply via email to