table name :Tab
fields name
1.trx_no (pk)
2.trx_date
3.account code (7 char)
4.account type (1 char)
5.amt
Tab contains account code day wise debit and credit transaction , account type fiels can have 2 value D for debit and c for Credit .

write a query to display the account code wise total debit and credit bal for the month of april 2004.

write a query to display account code wise new amt credit for the april 2004

Answer Posted / jayashree

SELECT SUM(DECODE(ACC_CODE, 'C', AMT)) Total_credit_bal,
SUM(DECODE(ACC_CODE, 'D', AMT)) Total_debit_bal
from tab
where to_char(trx_date,'DD-MON-YYYY') between
'01-apr-2014' and '30-apr-2014';

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is data manipulation language?

880


What's the procedure?

665


Are there any features that are decommissioned in 11g that are not present in 11g?

1819


What is set serveroutput on in pl sql?

814


What is scalar function in sql?

706






What are the advantages of pl sql?

835


What packages(if any) has oracle provided for use by developers?

5323


Which column of the user triggers data dictionary view displays the database event that will fire the trigger?

777


What is trigger and how to use it in sql?

723


What is native sql query?

738


Is sql database free?

701


Can you join views in sql?

720


How does index help in query performance?

763


What is the difference between subquery and correlated query?

724


how can we know the number of days between two given dates using mysql? : Sql dba

746