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 / prativa mishra

SELECT trans_id,MAX(TRANS_AMOUNT),MIN(TRANS_AMOUNT),DEBIT_CREDIT_INDICATOR
FROM CUSTOMER
GROUP BY TRANS_ID
,DEBIT_CREDIT_INDICATOR
ORDER BY TRANS_ID

Is This Answer Correct ?    8 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is primary key always clustered index?

536


How to run sql statements through the web interface?

514


What are the syntax and use of the coalesce function?

553


Why do we use procedures?

519


What is pivot table in sql?

524






Can we write ddl statements in functions?

569


What is a memo field?

529


What is a rank in sql?

538


What is the difference between sql and t sql?

538


What schema means?

525


Is sqlite free?

538


Why is pl sql needed?

517


Which tcp/ip port does sql server run on? How can it be changed? : Sql dba

495


What is the life of an sql statement?

525


Why do we go for stored procedures?

515