SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
/* Questions - 1. List of members who have done a transaction on 09-10-2021. Required columns - mobile, member_id, amount 2. Find the member who has the spent the highest amount on 09-10-2021 using aggregate functions. */ CREATE TABLE members ( id INT, member_id VARCHAR(20), mobile VARCHAR(20), date_of_birth VARCHAR(20), PRIMARY KEY (member_id) ); INSERT INTO members (id, member_id, mobile, date_of_birth) values (1,'member_1','+919432122222', '10-10-1999'), (2,'member_2','+919132122222', '12-11-1979'), (3,'member_3','+919532122222', '20-09-1989'), (4,'member_4','+919732122222', '09-05-1995'), (5,'member_5','+918732122222', '15-05-1995'); CREATE TABLE txn ( txn_id INT, amount INT, txn_date VARCHAR(20), member_id VARCHAR(20), PRIMARY KEY (txn_id), FOREIGN KEY (member_id) REFERENCES members(member_id) ); INSERT into txn (txn_id,amount,txn_date,member_id) values (1,100,'10-10-2021','member_1'), (2,450,'09-10-2021','member_2'), (3,100,'09-10-2021','member_3'), (4,100,'03-09-2021','member_4'); select * from members; select * from txn;

Stuck with a problem? Got Error? Ask ChatGPT!

Copy Clear