Loading DelightQL...
The following is a cheat sheet of the most common operations in SQL as programmed in delightql. For a complete list, please see the language reference. Notably, this list does not include things that delightql can do that SQL has no easy representation for. For a list of those, see new features.:
SELECT¶
users(*)
|> (first_name, last_name as LN, email)
DISTINCT¶
users(*) |> %(country,status)
GROUP BY¶
orders(*)
|> %(status ~> count:(%user_id))
WHERE¶
users(*), age > 25, country = "USA"
HAVING¶
users(*) |> %(country ~> count:(*) as user_count), user_count > 10
INNER JOIN ON¶
main.users(*) as u, main.orders(*) as o,
u.id = o.user_id
INNER JOIN USING¶
users(*),
orders(*.(status,created_at))
OUTER JOIN ON¶
users(*) as u, orders?(*) as o, u.id = o.user_id
SELECT (qualified)¶
orders(*) as o, users(*) as u,
o.user_id = u.id
|> (u.last_name as ln,
u.first_name,
age + 20 as age_20,
o.id,
o.total)
VALUES (inline data)¶
_(
product,price,quantity
-------------------------
"Laptop",999.99,5;
"Mouse",29.99,15;
"Keyboard",79.99,10
)
IN¶
users(*), status in ("active"; "pending"; "suspended")
users(*), (age, status) in (25, "active"; 30, "pending"; 35, "inactive")
CASE SEARCH¶
age_bucket:(a) :
_:(a>64 -> "older age";
a>0,a<20 -> "young";
a>=20, a<=40 -> "adult")
users(*)
|> (first_name, last_name, age_bucket:(age))
LIMIT¶
users(*), #<5
ORDER BY¶
users(*)
|> #(age descending,last_name ascending)
EXISTS¶
users(*) as u,
+orders(, u.id = o.user_id) as o
NOT EXISTS¶
users(*) as u,
\+orders(, u.id = o.user_id) as o
UNION ALL¶
users_2024(|> (first_name,last_name,email))
||
users_2023(|> (first_name,last_name,email))