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_date trans_amt debit_credit_indicator
001 JAN 1599 cr
no.of trans
2
i want trans_id and trans_date like 'JAN' or 'FEB' etc,
trans_amt i want all credit amount - debit amount per each
trans_id. and debit_credit_indicator and no.of transactions
in a month.
Answer / vinay
Select distinct trans_id ,
to_char(trans_date,'MON') as TRANS_DATE,
count(trans_amt) over (partition by trans_id,to_char
(trans_date,'MON')) as No_OF_TRANSACTION
,sum(trans_amt) over (partition by trans_id,to_char
(trans_date,'MON')) as TRANS_AMOUNT,
debit_credit_indicator from CUSTOMER
| Is This Answer Correct ? | 3 Yes | 0 No |
How many null values can be inserted in a coulmn whihc is unique constraint
What is cursor explain with example?
What is normalization ?
9 Answers BirlaSoft, CTS, HCL,
cursor types? explain with example programs?
What is a heap in sql?
what is a record in a database ? : Sql dba
What is use of trigger?
Explain foreign key in sql?
what is query cache in mysql? : Sql dba
How do you drop a trigger?
What has stored procedures in sql and how we can use it?
Can a procedure in a package be overloaded?
Oracle (3259)
SQL Server (4518)
MS Access (429)
MySQL (1402)
Postgre (483)
Sybase (267)
DB Architecture (141)
DB Administration (291)
DB Development (113)
SQL PLSQL (3330)
MongoDB (502)
IBM Informix (50)
Neo4j (82)
InfluxDB (0)
Apache CouchDB (44)
Firebird (5)
Database Management (1411)
Databases AllOther (288)