-
Notifications
You must be signed in to change notification settings - Fork 1k
Expand file tree
/
Copy pathquery.sql
More file actions
32 lines (28 loc) · 767 Bytes
/
query.sql
File metadata and controls
32 lines (28 loc) · 767 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
-- name: ListAuthorsColumnSort :many
SELECT * FROM authors
WHERE id > sqlc.arg(min_id)
ORDER BY CASE WHEN sqlc.arg(sort_column) = 'name' THEN name END;
-- name: ListAuthorsColumnSortDirection :many
SELECT * FROM authors
WHERE id > ?
ORDER BY
CASE
WHEN @order_by = 'asc' THEN name
END ASC,
CASE
WHEN @order_by = 'desc' OR @order_by IS NULL THEN name
END DESC;
-- name: ListAuthorsColumnSortFnWtihArg :many
SELECT * FROM authors
ORDER BY id % ?;
-- name: ListAuthorsNameSort :many
SELECT * FROM authors
WHERE id > sqlc.arg(min_id)
ORDER BY name ASC;
-- name: ListAuthorsNamedParamsOnly :many
SELECT * FROM authors
ORDER BY
CASE
WHEN @sort = 'name' THEN name
WHEN @sort = 'bio' THEN bio
END ASC;