You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1.5 KiB
1.5 KiB
SQL practices
ToC
Practice 1
- Count the number of subordinate 'ENTERPRISE_CUSTOMER' organizations for each organization.
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
;
Practice 2
- Calculate the center of each
japan_segment
.
SELECT
id,
ST_X(ST_Centroid(bounds)) AS "longitude",
ST_Y(ST_Centroid(bounds)) AS "latitude"
FROM japan_segments
;
Practice 3
- Select
japan_segments
within the bounds represented as the following GeoJSON.
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
130.27313232421875,
30.519681272749402
],
[
131.02020263671875,
30.519681272749402
],
[
131.02020263671875,
30.80909017893796
],
[
130.27313232421875,
30.80909017893796
],
[
130.27313232421875,
30.519681272749402
]
]
]
}
}
]
}