SQL: Bank Transaction

/*Exercise No:22 create bank transaction File*/ --create database with name bank and use it with its name create database bank; use bank; --create table with the following fields create table bank_table(ac_number int(15),c_name varchar(20),ac_type char(2), balance int(15), dot date, t_amount int(15),t_type char(1)); --inserting all the records ito the table bank_table insert into bank_table (ac_number,c_name,ac_type,balance,dot,t_amount,t_type) values(123456,'swati','sb',9000,'2022-12-19',100,'W'); insert into bank_table (ac_number,c_name,ac_type,balance,dot,t_amount,t_type) values(123457,'chran','sb',9000,'2022-11-19',500,'D'); insert into bank_table (ac_number,c_name,ac_type,balance,dot,t_amount,t_type) values(123459,'raju','ca',5000,'2022-09-19',300,'D'); insert into bank_table (ac_number,c_name,ac_type,balance,dot,t_amount,t_type) values(123458,'santhosh','ca',10000,'2022-10-16',500,'w'); insert into bank_table (ac_number,c_name,ac_type,balance,dot,t_amount,t_type) values(123455,'poojitha','sb',2000,'2022-10-19',500,'w'); insert into bank_table (ac_number,c_name,ac_type,balance,dot,t_amount,t_type) values(12653,'kushi','ca',4000,'2022-10-19',1500,'w'); insert into bank_table (ac_number,c_name,ac_type,balance,dot,t_amount,t_type) values(64378,'Rohith','ca',29000,'2022-11-10',500,'w'); insert into bank_table (ac_number,c_name,ac_type,balance,dot,t_amount,t_type) values(345721,'phaniraj','sb',9000,'2022-11-19',500,'D'); insert into bank_table (ac_number,c_name,ac_type,balance,dot,t_amount,t_type) values(765430,'kumar','ca',2550,'2022-10-19',500,'w'); insert into bank_table (ac_number,c_name,ac_type,balance,dot,t_amount,t_type) values(376520,'Rani','ca',92000,'2022-05-19',500,'D'); --i) FIND THE NAMES OF ALL CUSTOMERS WHOSE BALANCE AMOUNT IS MORE THAN 100000 select * from bank_table where balance>100000; --ii)FIND THE NUMBER OF CUSTOMERS WHOSE BALANCE IS LESS THAN MINIMUN i.e. MINIMUM BALANCE IS 1000: select count(*) from bank_table where balance <1000; --iii)TRANSACTION:update the records using where clause whose transction type is D and W. update bank_table set balance=balance+t_amount where t_type='D'; update bank_table set balance=balance-t_amount where t_type='W'; --iv)) DISPLAY TRANSACTION ON A PARTICULAR DAY: using where clause and with select query. select * from bank_table where dot='2022-11-10'; --v)DISPLAY ALL THE RECORDS OF SB ACCOUNT: select * from bank_table where ac_type='sb'; -- End of Exercise.

Comments

Popular posts from this blog

Karnataka I PUC Computer Science 2024 Study Material | SECOND PUC HANDBOOK EXAM 2025

PYTHON: Tips and Tricks