50% found this document useful (2 votes)
1K views

Practice Practical 4

1. This document contains SQL queries to retrieve information from tables related to bank accounts, loans, installments and transactions. 2. The queries select, group, filter and join data from multiple tables to show account balances, loan amounts, transaction details and more for analysis. 3. Information like city sums, below average installments, last few rows, specific months and loan/transaction matches are queried.

Uploaded by

parmar shyam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
50% found this document useful (2 votes)
1K views

Practice Practical 4

1. This document contains SQL queries to retrieve information from tables related to bank accounts, loans, installments and transactions. 2. The queries select, group, filter and join data from multiple tables to show account balances, loan amounts, transaction details and more for analysis. 3. Information like city sums, below average installments, last few rows, specific months and loan/transaction matches are queried.

Uploaded by

parmar shyam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

1.

Display the sum of balance of account holders who s live in same city
Mehsana using group by clause.
==>select sum(balance) from account group by city having city='Mehsana';
2. Display the information about account where balance is less than total
balance of all account holders.
==>select * from account where balance<(select sum(balance) from account);
3. Displays the information of account holders whose loan amount and
balance both are same.
==> select * from account,loan where account.balance=loan.loan_amt;
4. Display the name of city, remaining loan amount, account, date of
loan and loan number of account holders.
==>select account.city,loan.remaining_loan,account.acc_no,loan.loan_no,loan.loan
_date from account,loan where account.acc_no=loan.acc_no;
5. Display name of account holder, installment number and installment
amount Whose loan number is L001 .
==>select account.name,installment.inst_no,installment.amount from loan,account,
installment where account.acc_no=loan.acc_no and loan.loan_no=installment.loan_n
o and loan.loan_no='L001' ;
6. Display name of account holder, city, loan amount and installment
amount.
==>select account.name,account.city,loan.loan_amt,installment.amount from accoun
t,loan,installment;
7. Display the balance of account holders whose balance and remaining
loan both are same.
==>select balance from account,loan where account.balance=loan.remaining_loan;
8. List of all account holders
loan amount.

information whose balance is same as

==> select account.balance,account.name,account.city,account.balance,account.loa


n_taken from account,loan where account.balance=loan.loan_amt;
9. Display the amount of transaction, name of account holders, account
number and mode of payment whose mode of payment is
==> select transaction.amt,account.name,account.acc_no,transaction.mode_of_pay f
rom account,transaction where mode_of_pay='Cash';
10. Display account no, loan amount, amount of transaction.
==> select transaction.acc_no,loan.loan_amt,transaction.amt from transaction,loa
n where transaction.acc_no=loan.acc_no;
11. List of installment information whose amount is less than average
amount of transaction.
==> select * from installment where amount<(select avg(amount) from transaction)
;
12. Display the sum of installment amount and transaction amount.

==> select sum(installment.amount),sum(transaction.amt) from transaction,install


ment;
13. Display the balance and amount of transaction group by amount and
balance.
==> select sum(account.balance),sum(transaction.amt) from transaction,account wh
ere transaction.acc_no=account.acc_no;
14. List of installment number and account number of account holders.
==> select installment.inst_no,account.acc_no from account,installment,loan wher
e account.acc_no=loan.acc_no and loan.loan_no=installment.loan_no;
15. Display loan amount, transaction amount and mode of payment
where transaction date and loan taken date both are done in month of
==> select loan.loan_amt,transaction.amt,transaction.mode_of_pay from transactio
n,loan where transaction.acc_no=loan.acc_no and to_char(loan.loan_date,'MON')='M
AY' and to_char(transaction.tr_date,'MON')='MAY';
16. display all the information of installment and transaction where
installment date and transaction date both are done in month of
==> select * from transaction,installment where to_char(installment.idate,'MON'
)=to_char(transaction.tr_date,'MON');
17. Display the last three row of account table.
==>
select * from account minus select * from account where rownum<=(select (count(*
)-3) from account);
18. Display the balance, mode of payment, loan taken status whose mode
of payment is CHEQUE and loan taken is YES .
==> select account.balance,transaction.mode_of_pay,account.loan_taken from accou
nt,transaction where account.acc_no=transaction.acc_no and transaction.mode_of_p
ay='Cheque' and account.loan_taken='YES';
19.how to Retrieve only rows 2 to 5 from table.
==> select * from account minus select * from account minus select * from accoun
t where rownum<=(select (count(*)-5) from account);

You might also like