What SQL is, and why professionals learn it
Last updated
SQL is how you ask a database a question and get a table back. You describe the rows you want, and the database does the work of finding them. That is the whole idea.
You do not need to be an analyst to want this. If you make decisions, you depend on numbers, and waiting on someone else to pull them is slow and easy to second-guess. SQL lets you answer your own question and check the figure behind a decision before you act on it. It is also the language under almost every analytics tool. Power BI, Tableau, Metabase, and Looker all send SQL to a database for you, so reading and writing a little of it yourself pays off everywhere.
The dataset you will use all course
Every lesson queries the same small shop: a Southeast Asian software business with customers, products, orders, and the line items inside each order. Keeping one dataset means you build a mental picture of it and focus on the SQL, not on relearning the tables each time.
customers:who bought, and which city they are inproducts:what is for sale, its category and priceorders:one row per order, with a statusorder_items:which products, and how many, are in each order
Run your first query
The box below is a real SQLite database running inside your browser. Nothing is sent anywhere and nothing is saved. Press Run to see every row in customers. Edit the query and run it again as often as you like. Reset puts it back to the starting point.
Press Run to see the customers table.
CREATE TABLE customers ( id INTEGER PRIMARY KEY, name TEXT, city TEXT, signup_date TEXT ); INSERT INTO customers VALUES (1, 'Aisyah Rahman', 'Kuala Lumpur', '2023-01-12'), (2, 'Lim Wei Jie', 'Penang', '2023-02-03'), (3, 'Arjun Pillai', 'Johor Bahru', '2023-02-20'), (4, 'Nurul Huda', 'Kuala Lumpur', '2023-03-15'), (5, 'Tan Mei Ling', 'Ipoh', '2023-05-01'), (6, 'Faiz Hassan', 'Penang', '2023-06-10'); CREATE TABLE products ( id INTEGER PRIMARY KEY, name TEXT, category TEXT, price REAL ); INSERT INTO products VALUES (1, 'Standard License', 'Software', 199.0), (2, 'Pro License', 'Software', 499.0), (3, 'Onboarding Workshop', 'Service', 1200.0), (4, 'Support Plan', 'Service', 300.0), (5, 'Data Pack', 'Add-on', 89.0); CREATE TABLE orders ( id INTEGER PRIMARY KEY, customer_id INTEGER, order_date TEXT, status TEXT ); INSERT INTO orders VALUES (1001, 1, '2023-03-01', 'paid'), (1002, 1, '2023-04-12', 'paid'), (1003, 2, '2023-04-15', 'paid'), (1004, 3, '2023-05-02', 'refunded'), (1005, 4, '2023-05-20', 'paid'), (1006, 2, '2023-06-01', 'pending'), (1007, 5, '2023-06-18', 'paid'); CREATE TABLE order_items ( order_id INTEGER, product_id INTEGER, quantity INTEGER ); INSERT INTO order_items VALUES (1001, 1, 2), (1001, 5, 1), (1002, 2, 1), (1003, 1, 1), (1003, 4, 1), (1004, 3, 1), (1005, 2, 2), (1005, 5, 3), (1006, 1, 1), (1007, 3, 1), (1007, 4, 2);
SELECT * FROM customers;
That * means "every column". You just read a table out of a database. The rest of the course is learning to ask for exactly the rows and columns you need.
The playground runs entirely in your browser on a copy of the data. Nothing you type is saved or sent anywhere, so experiment freely. Refreshing the page or pressing Reset puts the sample database back to the start.
Where do the queries in this course actually run?