[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index] [Date Index] [Thread Index]
[SQR-USERS Info] [SQRUG Home Page]

Re: [sqr-users] Order by the values obtained in the amount columns



thanks alot .... i will try to use mutliple selects or by using arrays and 
dumpin it back when printing ......
   
   
   
   
  

Larry Roux <lroux@syr.edu> wrote:
  The best method would be to use multiple selects. ie 

select cust_name , item_amt , billable_flg 
from ps_xxx
where billable_flg = 'N' and item_amt > 0 
order by cust_name, item_amt

then

select cust_name , item_amt , billable_flg 
from ps_xxx
where billable_flg = 'N' and item_amt = 0 
order by cust_name

then

select cust_name , item_amt , billable_flg 
from ps_xxx
where billable_flg = 'Y'
order by cust_name, item_amt

There are probably a few ways to use creative SQL, but they would be
less efficient and slower - not to mention using up lots of memory on
your RDBMS box



Larry Roux
Information Systems
Syracuse University
lroux@syr.edu

>>> ashwin443@yahoo.co.uk 03/06/07 5:45 PM >>>
I am having a small problem in figurin this out maybe someone has done
this before 

Here is my problem ..... here is the sql i have written

select cust_name , item_amt , billable_flg 
from ps_xxx
where ....
order by billable_flg desc , cust_name

The output will order by billable_flg and customer name .... here is
the result of the output 

billable_flg name item_amt
Y A..... 123.22
Y B.... 0.00
Y C.... 21.00
N A.... 213.22
N B.... 321.22

what i am finally supposed to do is ....to put all the item_amt which
are equal to zero at the end but just before the billable_flg is changed
to 'N' from 'Y'

final output required

billable_flg name item_amt
Y A..... 123.22
Y C.... 21.00
Y B.... 0.00
N A.... 213.22
N B.... 321.22

any ideas on how to do it ...even if u know some order by syntaxes
that i can try let me know i can test it on my query

Thanks,
Ashwin


---------------------------------
New Yahoo! Mail is the ultimate force in competitive emailing. Find out
more at the Yahoo! Mail Championships. Plus: play games and win prizes.

_______________________________________________
sqr-users mailing list
sqr-users@sqrug.org
http://www.sqrug.org/mailman/listinfo/sqr-users



                
---------------------------------
 All New Yahoo! Mail – Tired of unwanted email come-ons? Let our SpamGuard 
protect you.

_______________________________________________
sqr-users mailing list
sqr-users@sqrug.org
http://www.sqrug.org/mailman/listinfo/sqr-users