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.

pls give me answer. i want urgent

Answer Posted / srinu.g

SELECT
trans_id,MAX(TRANS_AMOUNT),MIN(TRANS_AMOUNT),DEBIT_CREDIT_INDICATOR
FROM CUSTOMER WHERE DEBIT_CREDIT_INDICATOR='cr'
UNION ALL
SELECT
trans_id,MAX(TRANS_AMOUNT),MIN(TRANS_AMOUNT),DEBIT_CREDIT_INDICATOR
FROM CUSTOMER WHERE DEBIT_CREDIT_INDICATOR='db'

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the use of desc in sql?

496


What does (*) mean in sql?

527


Does sql*plus also have a pl/sql engine?

563


Does inner join remove duplicates?

522


How we can create a table in pl/sql block. Insert records into it? Is it possible by some procedure or function? Please give example?

595






Is json a nosql?

541


What is set transaction?

582


What are different types of queries in sql?

525


How we can update the view?

601


How many sectors are in a partition?

564


what is table? : Sql dba

572


What are aggregate functions in sql?

629


What are the benefits of pl/sql packages?

541


What is difference between primary and secondary key?

519


How do I run a query in pl sql developer?

562