Last active
July 31, 2018 08:05
-
-
Save toyeiei/4c80e6523fa7eb09e1a8fe5725277b35 to your computer and use it in GitHub Desktop.
Introduction to SQL for everyone part I
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- SELECT clause to select specific columns | |
-- Select all columns from customers table | |
SELECT * FROM customers; | |
-- Select firstname, lastname and address columns from customers table | |
SELECT firstname, lastname, address FROM customers; | |
-- Use AS (alias) to change the column name | |
SELECT | |
firstname AS customer_firstname, | |
lastname AS customer_lastname | |
FROM | |
customers; | |
-- Calculate new columns | |
SELECT revenue - expenditure AS profit | |
FROM finances; | |
-- WHERE clause to filter rows | |
-- Select customers who live in Thailand | |
SELECT * FROM customers | |
WHERE country = 'Thailand'; | |
-- Select customers who live in Thailand or Canada | |
SELECT * FROM customers | |
WHERE country = 'Thailand' OR country = 'Canada'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment