Skip to main content

max / makenotwork

1.0 KB · 35 lines History Blame Raw
1 {
2 "db_name": "PostgreSQL",
3 "query": "\n SELECT p.id AS \"id: ProjectId\", p.title, COALESCE(SUM(t.amount_cents), 0)::BIGINT AS \"revenue!\"\n FROM projects p\n LEFT JOIN items i ON i.project_id = p.id\n LEFT JOIN transactions t ON t.item_id = i.id AND t.status = 'completed'\n WHERE p.user_id = $1\n GROUP BY p.id, p.title\n HAVING COALESCE(SUM(t.amount_cents), 0) > 0\n ORDER BY COALESCE(SUM(t.amount_cents), 0) DESC\n ",
4 "describe": {
5 "columns": [
6 {
7 "ordinal": 0,
8 "name": "id: ProjectId",
9 "type_info": "Uuid"
10 },
11 {
12 "ordinal": 1,
13 "name": "title",
14 "type_info": "Varchar"
15 },
16 {
17 "ordinal": 2,
18 "name": "revenue!",
19 "type_info": "Int8"
20 }
21 ],
22 "parameters": {
23 "Left": [
24 "Uuid"
25 ]
26 },
27 "nullable": [
28 false,
29 false,
30 null
31 ]
32 },
33 "hash": "ae362df7a9f9899591d1b2e0f722cdf4397d849f9837158e893da24945e18dbc"
34 }
35