Practice & Assessment
Test your understanding of SQL Fundamentals
Multiple Choice Questions
5In what order does SQL logically process the clauses of a SELECT statement?
What does a LEFT JOIN return that an INNER JOIN does not?
What is the safest way to test a DELETE operation before executing it?
Which SQL clause filters results AFTER aggregation?
What is the difference between DELETE and TRUNCATE?
Coding Challenges
1Write Complex Multi-Table Queries
Using an orders database with tables: customers (customer_id, name, email, city), orders (order_id, customer_id, order_date, status, total_amount), order_items (order_id, product_id, quantity, unit_price), products (product_id, name, category, price). Write the following queries: (1) List all customers from Mumbai who placed orders in 2024, showing customer name, order count, and total spent. (2) Find the top 5 products by total revenue (quantity × unit_price). (3) Find customers who placed orders but never ordered from the 'Electronics' category. (4) Update all 'pending' orders older than 30 days to 'cancelled'.
Mini Project
Blog Platform Database with Full SQL Operations
Design and implement a blog platform database. Tables required: users (user_id, username, email, password_hash, bio, created_at), posts (post_id, user_id, title, slug, content, status, published_at, created_at), tags (tag_id, name, slug), post_tags (post_id, tag_id), comments (comment_id, post_id, user_id, content, created_at, parent_comment_id for nested comments). Write SQL for: (1) Create all tables with proper constraints and foreign keys. (2) Fetch all published posts with author name, comment count, and tags. (3) Find the top 5 most commented posts this month. (4) Find all posts by a specific author. (5) Soft-delete a post (set status to 'deleted' instead of removing the row). (6) Calculate each author's total post count and average comments per post.
