{"id":21431671,"url":"https://github.com/tomdoestech/learn-sql","last_synced_at":"2026-01-03T15:05:54.411Z","repository":{"id":233695631,"uuid":"667722729","full_name":"TomDoesTech/learn-sql","owner":"TomDoesTech","description":null,"archived":false,"fork":false,"pushed_at":"2023-07-18T06:54:26.000Z","size":26,"stargazers_count":7,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-23T08:41:32.608Z","etag":null,"topics":["sql"],"latest_commit_sha":null,"homepage":"https://youtu.be/B4RdHmLqeoM","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TomDoesTech.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2023-07-18T06:54:02.000Z","updated_at":"2024-12-27T13:11:16.000Z","dependencies_parsed_at":null,"dependency_job_id":"09f4eef8-30e8-4125-ad60-02d9bebc5fd2","html_url":"https://github.com/TomDoesTech/learn-sql","commit_stats":null,"previous_names":["tomdoestech/learn-sql"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TomDoesTech%2Flearn-sql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TomDoesTech%2Flearn-sql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TomDoesTech%2Flearn-sql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TomDoesTech%2Flearn-sql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TomDoesTech","download_url":"https://codeload.github.com/TomDoesTech/learn-sql/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243941766,"owners_count":20372302,"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":["sql"],"created_at":"2024-11-22T23:11:33.468Z","updated_at":"2026-01-03T15:05:54.367Z","avatar_url":"https://github.com/TomDoesTech.png","language":null,"readme":"1. Getting started\n\n\n## Queries and filters\n### SELECT\n\n```\nSELECT * FROM jobs;\n```\n\n\n### WHERE\n```\nSELECT * from jobs\nWHERE job_id = 1;\n```\n\n```SELECT * from jobs\nWHERE min_salary \u003e 4000\nAND min_salary \u003c 5000;\n```\n\n### ORDER BY\n```\nSELECT * from jobs\nWHERE min_salary \u003e 1000\nAND min_salary \u003c 8000\nORDER BY min_salary;\n```\n\n```\nSELECT * from jobs\nWHERE min_salary \u003e 1000\nAND min_salary \u003c 8000\nORDER BY min_salary DESC;\n```\n\n### LIMIT\n```\nSELECT * from jobs\nWHERE min_salary \u003e 1000\nAND min_salary \u003c 8000\nORDER BY min_salary DESC\nLIMIT 5;\n```\n\n## Aggregations\n\n### AVG\n```\nSELECT AVG(min_salary) AS avg_min_salary,\nAVG(max_salary) AS avg_max_salary\nFROM jobs;\n```\n\n\n### COUNT\n```\nSELECT COUNT(*) AS total_jobs\nFROM jobs;\n```\n\n### MAX\n```\nSELECT MAX(min_salary) AS max_min_salary,\nMAX(max_salary) AS max_max_salary\nFROM jobs;\n```\n\n### MIN\n```\nSELECT MIN(min_salary) AS min_min_salary,\nMIN(max_salary) AS min_max_salary\nFROM jobs;\n```\n\n\n## Grouping\n### GROUP BY\n```\nSELECT department_id, COUNT(*) AS total_employees\nFROM employees\nGROUP BY department_id;\n```\n\n### HAVING\n```\nSELECT department_id, COUNT(*) AS total_employees\nFROM employees\nGROUP BY department_id\nHAVING COUNT(*) \u003e 5;\n```\n\n## Joins\n### INNER JOIN\nAn inner join will return only the rows that match in both tables.\n```\nSELECT * FROM employees\nINNER JOIN departments\nON employees.department_id = departments.department_id;\n```\n\n### LEFT JOIN\nA left join will return all the rows from the left table, and the matched rows from the right table.\n\nIn the query below, all the employees will be returned, even if they don't have a department because employees is the left table.\n```\nSELECT * FROM employees\nLEFT JOIN departments\nON employees.department_id = departments.department_id;\n```\n\n### RIGHT JOIN\nA right join will return all the rows from the right table, and the matched rows from the left table.\n\nIn the query below, all the departments will be returned, even if they don't have an employee because departments is the right table.\n```\nSELECT * FROM employees\nRIGHT JOIN departments\nON employees.department_id = departments.department_id;\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomdoestech%2Flearn-sql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftomdoestech%2Flearn-sql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomdoestech%2Flearn-sql/lists"}