Professional Documents
Culture Documents
SQL Cheat Sheet
SQL Cheat Sheet
—- Delete data
DELETE FROM invoices
WHERE client_id = (
SELECT client_id
FROM clients
WHERE name = 'Myworks')
Aggregate Functions
—- MAX, MIN, AVG, SUM and COUNT
SELECT
MAX(invoice_total) AS highest,
MIN(invoice_total) AS lowest,
AVG(invoice_total) AS average,
SUM(invoice_total) AS total,
COUNT(invoice_total) AS number_of_invoices,
COUNT(payment_date) AS count_of_payments,
FROM invoices