i have a customer table.
trans_id trans_date trans_amt debit_credit_indicator
001 01-JAN-13 1099 cr
001 12-JAN-13 500 db
002 24-FEB-13 400 db
002 23-MAR-13 345 cr
001 18-APR-13 800 cr
002 15-MAR-13 600 db
001 12-FEB-13 200 cr

i want like this output.

trans_id trans_amt debit_credit_indicator

i want get highest credit amount and lowest credit amount
and highest debit amount and lowest debit amount for each
trans_id.

Answer Posted / ajit

select ac_no, max(AC_STATUS) high,min(AC_STATUS) low,ac_branch
from DIM_ACCOUNt
where ac_branch = 'cr'
and ac_no = 1
group by ac_no, ac_branch
union
select ac_no, max(AC_STATUS) high,min(AC_STATUS) low,ac_branch
from DIM_ACCOUNt
where ac_branch = 'cr'
and ac_no = 2
group by ac_no, ac_branch
union
select ac_no, max(AC_STATUS) high,min(AC_STATUS) low,ac_branch
from DIM_ACCOUNt
where ac_branch = 'db'
and ac_no = 2
group by ac_no, ac_branch
union
select ac_no, max(AC_STATUS) high,min(AC_STATUS) low,ac_branch
from DIM_ACCOUNt
where ac_branch = 'db'
and ac_no = 1
group by ac_no, ac_branch;

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are sql indexes?

547


How to select 10 records from a table?

650


What is rename command in sql?

468


What is the use of primary key?

539


What is thread join () in threading?

542






What is sqlcommand?

558


What is the sql*loader? : aql loader

591


How do you rank data in sql?

517


What are the three forms of normalization?

535


What is pl sql block structure?

545


Why is sql*loader direct path so fast?

603


What are the different ddl commands in sql?

582


Can I learn sql in a week?

554


What are the uses of merge?

724


Can %notfound return null after a fetch?

593