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
Answers were Sorted based on User's Feedback
Answer / ritika yadav
select account_code,account_type, sum (amt)
from tab
where to_char(trx_date,'DD-MM-YYYY') between '01-04-2014' and '30-04-2014'
group by account_code, account_type
order by account_code, account_type;
Is This Answer Correct ? | 2 Yes | 0 No |
Answer / 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 |
how will u find statistics of a database objects?
what is 'mysqldump'? : Sql dba
Can you join views in sql?
what is 'mysqlcheck'? : Sql dba
How can we link a sql database to an existing android app?
Why we use sql profiler?
Explain cursor types?
Which join is like an inner join?
which tcp/ip port does sql server run on? : Sql dba
how to rename an existing column in a table? : Sql dba
Can we join same table in sql?
what happens if null values are involved in expressions? : Sql dba