Home » RDBMS Server » Server Administration » Order By
Order By [message #373809] Mon, 14 May 2001 02:05 Go to next message
momen
Messages: 9
Registered: May 2001
Junior Member
Hi all,

I have a Voucher Table and I need to select the debit transactions first, and among debit trans. it should be ordered by all Items of type 'B' and then 'A'. Here is the table desc. & a sample data.

Vou_No Serial Item_No Item_Type Debit Credit
-------------------------------------------------------------
200010 1 1910300 A 0 698
200010 2 1910300 A 0 741
200010 3 1910300 A 0 751
200010 4 1910300 A 0 350
200010 5 1910300 A 0 254
200010 6 8510300 A 0 662
200010 7 3302000 A 3090 0
200010 8 0110100 B 450 0
200010 9 031000 B 0 84

The o/p should be
Vou_No Serial Item_No Item_Type Debit Credit
---------------------------------------------
200010 8 0110100 B 450 0
200010 7 3302000 A 3090 0
200010 9 031000 B 0 84
200010 1 1910300 A 0 698
200010 2 1910300 A 0 741
200010 3 1910300 A 0 751
200010 4 1910300 A 0 350
200010 5 1910300 A 0 254
200010 6 8510300 A 0 662

Any help will be appreciated.

Thanks in advance.
Regards,

Momen.
Re: Order By [message #373850 is a reply to message #373809] Tue, 15 May 2001 17:01 Go to previous messageGo to next message
Sundar Venkatasubramaniam
Messages: 26
Registered: May 2001
Junior Member
If you want other than this please explain in more detail.

Assume all are non null fields
do you want to try this
select * from voucher order by to_number(ascii(Item_Type) ||rpad(Debit,90,0)) desc
Re: Order By [message #373851 is a reply to message #373809] Tue, 15 May 2001 17:06 Go to previous message
Sundar Venkatasubramaniam
Messages: 26
Registered: May 2001
Junior Member
If you want other than this please explain in more detail.

Assume all are non null fields
do you want to try this
select * from voucher order by to_number(ascii(Item_Type) ||rpad(Debit,90,0)) desc
Previous Topic: Masking special characters in SQLPLUS
Next Topic: How to use count function to count insurance policy which more than one person hold?
Goto Forum:
  


Current Time: Mon Dec 23 10:34:57 CST 2024