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
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 |
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 |
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 |
What program will open a mdb file?
What operators deal with null?
Hi Guys, I have a situation where I need to access the column values from rowtype variable. However, the column names are dynamic. below is sample code: declare Cursor c1 is select * from emp; Cursor c2 is select column_name from xyztable; v_c2 c2%rowtype; v_str varchar2 v_value varchar2(200); begin for rec in c1 loop open c2;---this cursor has column names like EMPLOYEE_ID, FIRST_NAME, LAST_NAME etc. loop fetch c2 into v_c2; exit when c2%notfound; /* now lets say i want to access value of LAST_NAME from cursor c1, so I am writing below code, however it does not work as expected */ v_str:= 'rec.'|| v_c2.column_name; -- this will give me string like "rec.EMPLOYEE_ID" v_value:=v_str; end loop; end loop; end; / Plz help ASAP.Thanks.
there is A table and B table in A table there 5 rows and in b table there are 2 rows i am firing query select * from a,b what will be the output?
What is primary key and foreign key with example?
Can we alter stored procedure?
Why primary key is required?
Can you select everything, but 1 or 2 fields, without writer's cramp?
What is bind reference and how can it be created?
What is procedure and function?
What is Difference Between delete and Truncate?
which will fire first ? Trigger or Constraint
24 Answers i2, IBM,