<aside> 💡 In this project, I’ve developed a series of SQL queries to analyze data related to dog ownership and subscriptions. Starting with basic queries such as listing dogs alphabetically, I progressed to more detailed queries—counting dogs per owner, calculating total subscription costs, and examining all subscriptions, active or not. The final query highlights subscriptions with multiple dogs, reflecting my growing proficiency in SQL and data analysis for pet-related data.
</aside>
<aside> 📌 Each Queries gets more and more Complex
</aside>

Table of content:
SELECT "Name" AS "DogName" FROM "DOGS" ORDER BY "DogName" ASC
| DogName |
|---|
| Boots |
| Duke |
| Junebug |
| Spot |
SELECT "OWNERS"."Name" AS "OwnerName", COUNT( * ) AS "DogCount"
FROM "DOGS", "OWNERS”
WHERE "DOGS"."Owner" = "OWNERS"."RowID"
GROUP BY "OWNERS"."RowID", "OwnerName"
ORDER BY "DogCount" ASC
| OwnerName | DogCount |
|---|---|
| Coco | 1 |
| Bai | 1 |
| Molokai | 2 |
SELECT "OWNERS"."Name" AS "Owner", SUM( "PLANS"."Cost" ) AS "Total Cost”
FROM "DOGS", "OWNERS", "SUBSCRIPTIONS", "PLANS"
WHERE "DOGS"."Owner" = "OWNERS"."RowID" AND "DOGS"."RowID" = "DOGS"."RowID" AND "SUBSCRIPTIONS"."Dog" = "DOGS"."RowID" AND "SUBSCRIPTIONS"."Plan" = "PLANS"."RowID" AND "SUBSCRIPTIONS"."Ended" IS NULL GROUP BY "OWNERS"."RowID", "OWNERS"."Name"
| Owner | Total Cost |
|---|---|
| Bai | 99 |
| Molokai | 298 |
SELECT "OWNERS"."Name" AS "Owner", SUM( "PLANS"."Cost" ) AS "Total Cost"
FROM "DOGS", "OWNERS", "PLANS", "SUBSCRIPTIONS"
WHERE "DOGS"."Owner" = "OWNERS"."RowID" AND "PLANS"."RowID" = "SUBSCRIPTIONS"."Plan" AND "SUBSCRIPTIONS"."Dog" = "DOGS"."RowID"
GROUP BY "OWNERS"."Name", "OWNERS"."RowID"
| Owner | Total Cost |
|---|---|
| Bai | 148 |
| Molokai | 495 |
For this Query I used LibreOffice Relationship Builder
SELECT "SUBSCRIPTIONS"."Plan" AS "Plan ID", "PLANS"."Level" AS "Plan Level", COUNT( "SUBSCRIPTIONS"."Dog" ) AS "Dog Count"
FROM "SUBSCRIPTIONS", "PLANS"
WHERE "SUBSCRIPTIONS"."Plan" = "PLANS"."RowID"
GROUP BY "SUBSCRIPTIONS"."Plan", "PLANS"."Level" HAVING ( ( COUNT( "SUBSCRIPTIONS"."Dog" ) > 1 ) )