|
|
@ -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) |
|
|
@ -87,7 +95,14 @@ class TestExample(DbTest): |
|
|
|
os.path.join(PATH_TO_SQL_DIR, "japan_segments.sql") |
|
|
|
) |
|
|
|
|
|
|
|
# PostGIS is very useful! |
|
|
|
sql = """ |
|
|
|
SELECT |
|
|
|
id, |
|
|
|
ST_X(ST_Centroid(bounds)) AS "longitude", |
|
|
|
ST_Y(ST_Centroid(bounds)) AS "latitude" |
|
|
|
FROM japan_segments |
|
|
|
; |
|
|
|
""" |
|
|
|
with conn.cursor(cursor_factory=RealDictCursor) as cur: |
|
|
|
cur.execute(sql) |
|
|
|