[Scenario 1]declare @table1 table( tran_no varchar(20), date datetime, credit int, debit int)insert into @table1select 'Cv/0001/2006', '20060612', 100, 0 union allselect 'Cv/0002/2006', '20060612', 100, 0 union allselect 'CP/0001/2006', '20060614', 0, 100select tran_no = max(tran_no), date = max(date), credit, debitfrom @table1group by credit, debit/* RESULTtran_no date credit debit -------------------- ------------------------------------------------------ ----------- ----------- Cv/0001/2006 2006-06-12 00:00:00.000 100 0CP/0001/2006 2006-06-14 00:00:00.000 0 100*/
Is this what you want ?
KH