adspace


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

Does group by remove duplicates?

1112


How do I remove duplicates in two columns?

1186


how to use regular expression in pattern match conditions? : Sql dba

1113


define sql insert statement ? : Sql dba

1098


If a cursor is open, how can we find in a pl/sql block?

1238


Do we need to rebuild index after truncate?

1138


What is the current version of sql?

1094


what is collation? : Sql dba

1229


what are the advantages of sql ? : Sql dba

1142


what is sql server agent? : Sql dba

1182


what is dbms? : Sql dba

1061


what are aggregate and scalar functions? : Sql dba

1129


Is primary key always clustered index?

1095


what is bcp? When does it used? : Sql dba

1055


how many tables will create when we create table, what are they? : Sql dba

1144