Query writing
From: Arif Gulzar <gulzar.arif_at_gmail.com>
Date: Wed, 18 Dec 2013 15:46:34 -0500
Message-ID: <CALMMNXTEiww4qTFMfhwcF9Uj7Fo55ztZ1cnWt_GhboOMDm3hyA_at_mail.gmail.com>
Please forward me following 2 quires. Thanks in advance.
4| 06/17/2013 12:50| 36.85
5| 06/17/2013 13:40|-523.58
please write a query which selects net daily turnovers (arithmetical sums of all transactions for a day) for all days when these turnovers are positive.
4 | 2 06/18/2013 200.00 NULL INTERNET PAYMENT 5 | 2 06/18/2013 500.00 0.00 MOB PHONE PAYMENT
Date: Wed, 18 Dec 2013 15:46:34 -0500
Message-ID: <CALMMNXTEiww4qTFMfhwcF9Uj7Fo55ztZ1cnWt_GhboOMDm3hyA_at_mail.gmail.com>
Please forward me following 2 quires. Thanks in advance.
*Q1: Given the following table of transactions in a cash register:*
id| trade_time | amount
-- ---------------- ------ 1| 06/16/2013 11:43| 52.00 2| 06/16/2013 11:50| 142.74 3| 06/16/2013 14:21| -43.89
4| 06/17/2013 12:50| 36.85
5| 06/17/2013 13:40|-523.58
please write a query which selects net daily turnovers (arithmetical sums of all transactions for a day) for all days when these turnovers are positive.
*Q2: Given the following two tables:*
clients (id (PK), name)
transactions (id (PK), client_id, trans_date, debit, credit, comment)
transactions.client_id references clients.id
please write a query which selects the balance for ALL clients, even if they have no transactions. (Assume initial balances to be zeros). Sample table contents:
clients:
id name
-- ------
1 John
2 Mary
3 Alex
transactions:
id client_id trans_date debit credit comment
-- --------- ---------- ------- ------- ----------------- 1 | 1 06/16/2013 NULL 1000.00 SALARY 2 | 1 06/18/2013 516.43 0.00 MOB PHONE PAYMENT 3 | 2 06/16/2013 NULL 1000.00 SALARY
4 | 2 06/18/2013 200.00 NULL INTERNET PAYMENT 5 | 2 06/18/2013 500.00 0.00 MOB PHONE PAYMENT
-- http://www.freelists.org/webpage/oracle-lReceived on Wed Dec 18 2013 - 21:46:34 CET