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

Answers were Sorted based on User's Feedback



i have a customer table. trans_id trans_date trans_amt debit_credit_indicator 001 01-..

Answer / 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

i have a customer table. trans_id trans_date trans_amt debit_credit_indicator 001 01-..

Answer / vinay

Select distinct trans_id,max(trans_amt) over (partition by
trans_id,debit_credit_indicator ),min(trans_amt) over
(partition by trans_id,debit_credit_indicator
),debit_credit_indicator from Customer

Is This Answer Correct ?    0 Yes 0 No

i have a customer table. trans_id trans_date trans_amt debit_credit_indicator 001 01-..

Answer / 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

More SQL PLSQL Interview Questions

What is self-join and what is the requirement of self-join?

0 Answers  


what is meant by urlencode and urldocode? : Sql dba

0 Answers  


what is difference between stored procedures and application procedures,stored function and application function?

1 Answers  


What is delete command in sql?

0 Answers  


why use cursors?

5 Answers   Oracle,






Is id a reserved word in sql?

0 Answers  


What is mutating trigger?

0 Answers  


Practice 1: Changes to data will only be allowed on tables during normal office hours of 8.45 in the morning until 5.30 in the afternoon, MONDAY through FRIDAY. A. Create a procedure called SECURE_DML that prevents the DML statement from executing outside of normal office hours, returning the message: “you may only make changes during normal office hours” b. Create a statement trigger on the PRODUCT table which calls the above procedure. c. Test it by inserting a new record in the PRODUCT table.

1 Answers   Tech Mahindra,


what is a record in a database ? : Sql dba

0 Answers  


what is 'trigger' in sql? : Sql dba

0 Answers  


what is meant by forward declaration in functions?

4 Answers   TCS,


What is sql clause?

0 Answers  


Categories