{"id":24482033,"url":"https://github.com/hillaryjude/beginner-to-advanced-sql-problem","last_synced_at":"2026-05-02T05:04:28.647Z","repository":{"id":273033553,"uuid":"918520598","full_name":"hillaryjude/Beginner-to-Advanced-Sql-Problem","owner":"hillaryjude","description":null,"archived":false,"fork":false,"pushed_at":"2025-01-18T06:25:53.000Z","size":252,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-21T08:05:12.048Z","etag":null,"topics":["database","farmers-database","mysql","sql"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hillaryjude.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-01-18T06:16:51.000Z","updated_at":"2025-01-18T06:27:37.000Z","dependencies_parsed_at":null,"dependency_job_id":"414fa87f-53b3-43fc-ab01-7060a1e48065","html_url":"https://github.com/hillaryjude/Beginner-to-Advanced-Sql-Problem","commit_stats":null,"previous_names":["hillaryjude/beginner-to-advanced-sql-problem"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/hillaryjude/Beginner-to-Advanced-Sql-Problem","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hillaryjude%2FBeginner-to-Advanced-Sql-Problem","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hillaryjude%2FBeginner-to-Advanced-Sql-Problem/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hillaryjude%2FBeginner-to-Advanced-Sql-Problem/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hillaryjude%2FBeginner-to-Advanced-Sql-Problem/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hillaryjude","download_url":"https://codeload.github.com/hillaryjude/Beginner-to-Advanced-Sql-Problem/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hillaryjude%2FBeginner-to-Advanced-Sql-Problem/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261088348,"owners_count":23107680,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database","farmers-database","mysql","sql"],"created_at":"2025-01-21T12:12:16.566Z","updated_at":"2026-05-02T05:04:28.642Z","avatar_url":"https://github.com/hillaryjude.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Farmers Market SQL Practice Problems (Part 1)\n\nWelcome to the Farmers Market SQL Practice Problems repository! This collection is designed for beginners looking to sharpen their SQL skills using practical queries based on a fictional Farmers Market database.\n\n## Getting Started\n\n### Prerequisites\n- Basic knowledge of SQL\n- SQL environment set up (e.g., MySQL, PostgreSQL, SQLite, etc.)\n\n### Database Schema\n\nThe Farmers Market database consists of the following tables:\n1. **products**\n2. **vendor_booth_assignments**\n3. **customer_purchases**\n4. **customers**\n5. **product_category**\n6. **market_date_info**\n\nEnsure you have these tables created in your database to proceed with the queries.\n\n### Problems and Solutions\n\n1. **Get all the products available in the market**\n    ```sql\n    SELECT * FROM farmers_market.product;\n    ```\n\n2. **List down 10 rows of farmer’s market vendor booth assignments, displaying the market date, vendor ID, and booth number from the vendor_booth_assignments table.**\n    ```sql\n    SELECT \n    market_date,\n    vendor_id,\n    booth_number\n    FROM farmers_market.vendor_booth_assignments\n    LIMIT 10;\n    ```\n\n3. **In the customer purchases, we have quantity and cost per qty separate. Query the total amount that the customer has paid along with date, customer ID, vendor ID, qty, cost per qty, and the total amount.**\n    ```sql\n    SELECT \n    vendor_id,\n    market_date,\n    customer_id,\n    quantity,\n    cost_to_customer_per_qty,\n    ROUND(quantity * cost_to_customer_per_qty, 2) AS 'Total amount'\n    FROM farmers_market.customer_purchases;\n    ```\n\n4. **Merge each customer’s name into a single column that contains the first name, then a space, and then the last name.**\n    ```sql\n    SELECT \n    CONCAT(customer_first_name, ' ', customer_last_name) AS 'Full name'\n    FROM customer;\n    ```\n\n5. **Extract all the product names that are part of product category 1.**\n    ```sql\n    SELECT product_category_id, product_category_name \n    FROM product_category\n    WHERE product_category_id = 1;\n    ```\n\n6. **Print a report of everything customer_id 4 has ever purchased at the farmer’s market, sorted by market date, vendor ID, and product ID.**\n    ```sql\n    SELECT \n    market_date,\n    vendor_id,\n    p.product_id,\n    p.product_name,\n    ROUND(quantity * cost_to_customer_per_qty, 2) AS 'Total amt'\n    FROM customer_purchases AS cp\n    LEFT JOIN farmers_market.product AS p\n    ON cp.product_id = p.product_id\n    WHERE customer_id = 4 \n    ORDER BY market_date, vendor_id, p.product_id;\n    ```\n\n7. **Get all the product info for products with id between 3 and 8 (not inclusive) and product with id 10.**\n    ```sql\n    SELECT \n    *\n    FROM PRODUCT\n    WHERE product_id = 10 OR (product_id \u003e 3 AND product_id \u003c 8);\n    ```\n\n8. **Details of all the purchases made by customer_id 4 at vendor_id 7, along with the total amount.**\n    ```sql\n    SELECT \n    market_date,\n    vendor_id,\n    product_id,\n    ROUND(quantity * cost_to_customer_per_qty, 2) AS 'Total amount'\n    FROM customer_purchases AS cp\n    WHERE customer_id = 4 \n    HAVING vendor_id = 7\n    ORDER BY market_date, vendor_id, product_id;\n    ```\n\n9. **Find the customer detail with the first name of “Carlos” or the last name of “Diaz”.**\n    ```sql\n    SELECT * FROM CUSTOMER\n    WHERE customer_first_name = 'Carlos' OR customer_last_name = 'Diaz';\n    ```\n\n10. **Find the booth assignments for vendor 7 for any market date that occurred between April 3, 2019, and May 16, 2019, including either of the two dates.**\n    ```sql\n    SELECT \n    market_date,\n    booth_number\n    FROM vendor_booth_assignments\n    WHERE vendor_id = 7 AND market_date BETWEEN '2019-04-03' AND '2019-05-16'\n    ORDER BY market_date;\n    ```\n\n11. **Return a list of customers with selected last names - [Diaz, Edwards, and Wilson].**\n    ```sql\n    SELECT \n    customer_id,\n    customer_first_name, \n    customer_last_name\n    FROM CUSTOMER\n    WHERE customer_first_name IN ('Diaz', 'Edwards', 'Wilson') OR customer_last_name IN ('Diaz', 'Edwards', 'Wilson');\n    ```\n\n12. **Analyze purchases made at the farmer’s market on days when it rained.**\n    ```sql\n    SELECT \n    market_date,\n    market_rain_flag,\n    cp.product_id,\n    ROUND(cp.quantity * cp.cost_to_customer_per_qty, 2) AS 'Total Amount'\n    FROM market_date_info AS md\n    JOIN customer_purchases AS cp ON md.market_date = cp.market_date\n    WHERE md.market_rain_flag = 'Y';\n    ```\n\n## Contributing\n\nFeel free to contribute to this repository by adding more beginner-friendly SQL practice problems or improving the solutions provided.\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n\n---\n\nHappy querying! 🚀\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhillaryjude%2Fbeginner-to-advanced-sql-problem","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhillaryjude%2Fbeginner-to-advanced-sql-problem","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhillaryjude%2Fbeginner-to-advanced-sql-problem/lists"}