From 5d03e883ec9d67d78730628de6d6a63bda60d4f8 Mon Sep 17 00:00:00 2001 From: Nathan Bergey Date: Tue, 13 Sep 2022 22:17:30 -0400 Subject: [PATCH] Test 1: Simple join with a count and group --- README.md | 2 ++ test/test_example.py | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/README.md b/README.md index b49d470..b187866 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ SQL test === +Nathan's SQL answers. Tests past in `test/test_example.py` + ### Prerequisistes ```bash diff --git a/test/test_example.py b/test/test_example.py index 43720a2..3904377 100644 --- a/test/test_example.py +++ b/test/test_example.py @@ -43,6 +43,14 @@ class TestExample(DbTest): ) sql = """ + SELECT + COUNT(customers.*) AS "subordinates_count", + organizations.id AS "id" + FROM organizations + LEFT OUTER JOIN enterprise_sales_enterprise_customers customers ON customers.sales_organization_id = organizations.id + GROUP BY organizations.id + ORDER BY organizations.id ASC + ; """ with conn.cursor(cursor_factory=RealDictCursor) as cur: cur.execute(sql)