SELECT a.store, MAX(qty) max_qty, b.product,
b.price * MAX(qty) AS total_price FROM sales a
LEFT JOIN products b ON a.p_id = b.p_id GROUP BY store;
store
max_qty
product
total_price
ABC
3
Monitor
225
DEF
2
CPU
110
6. List of products which are not sold
SELECT a.product , a.p_id FROM products a
LEFT JOIN sales b on a.p_id=b.p_id WHERE b.sale_id is null
product
p_id
Hard Disk
1
Keyboard
5
Mouse
6
Motherboard
7
Power supply
8
7. List of customers who have not purchased any product.
SELECT a.customer, a.c_id from customers a
LEFT JOIN sales b on a.c_id=b.c_id WHERE b.sale_id IS NULL
customer
c_id
King
5
Ronn
7
Jem
8
Tom
9
Master Relational Data with SQLite and Tkinter
Dive into the world of relational databases with this in-depth tutorial. Learn how to create and manage interconnected tables for products, customers, and sales using SQLite.
Enhance your Python applications by leveraging Tkinter to design user-friendly interfaces and generate dynamic reports. A perfect guide for mastering data relationships and
crafting interactive database-driven applications.
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery,
and web development at plus2net. The tutorials focus on clear explanations, working
examples, and code that readers can test and adapt while learning.