{"id":15002461,"url":"https://github.com/lnvaldez/stackoverflow-sql-queries","last_synced_at":"2025-10-30T08:31:19.436Z","repository":{"id":248167343,"uuid":"827954008","full_name":"lnvaldez/stackoverflow-sql-queries","owner":"lnvaldez","description":"SQL queries and resources for working with the Stack Overflow 10GB database provided by Brent Ozar.","archived":false,"fork":false,"pushed_at":"2024-07-16T20:31:49.000Z","size":20073,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-02T07:22:57.729Z","etag":null,"topics":["csv","csv-files","queries","query","rpt","sql","sql-server","sql-server-database","sql-server-management-studio","stackoverflow"],"latest_commit_sha":null,"homepage":"","language":"TSQL","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/lnvaldez.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":"2024-07-12T18:38:55.000Z","updated_at":"2024-07-25T09:51:17.000Z","dependencies_parsed_at":"2024-07-12T21:03:49.098Z","dependency_job_id":null,"html_url":"https://github.com/lnvaldez/stackoverflow-sql-queries","commit_stats":null,"previous_names":["lnvaldez/stackoverflow-sql"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lnvaldez%2Fstackoverflow-sql-queries","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lnvaldez%2Fstackoverflow-sql-queries/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lnvaldez%2Fstackoverflow-sql-queries/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lnvaldez%2Fstackoverflow-sql-queries/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lnvaldez","download_url":"https://codeload.github.com/lnvaldez/stackoverflow-sql-queries/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238945668,"owners_count":19556700,"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":["csv","csv-files","queries","query","rpt","sql","sql-server","sql-server-database","sql-server-management-studio","stackoverflow"],"created_at":"2024-09-24T18:50:27.199Z","updated_at":"2025-10-30T08:31:15.856Z","avatar_url":"https://github.com/lnvaldez.png","language":"TSQL","readme":"# Stack Overflow 10GB Database Queries \u003cbr\u003e ![Stack Overflow](https://img.shields.io/badge/-Stackoverflow-FE7A16?style=for-the-badge\u0026logo=stack-overflow\u0026logoColor=white)![MicrosoftSQLServer](https://img.shields.io/badge/Microsoft%20SQL%20Server-CC2927?style=for-the-badge\u0026logo=microsoft%20sql%20server\u0026logoColor=white)\n\nThis repository contains SQL queries and resources for working with the Stack Overflow 10GB database provided by Brent Ozar.\n\n### Prerequisites\n\nTo use the Stack Overflow database, you will need:\n\n- SQL Server Management Studio (SSMS) or another SQL database management tool.\n- Sufficient disk space (approximately 10GB) and system resources.\n\n### Downloading the Database\n\nYou can download the Stack Overflow 10GB database from Brent Ozar's website. Go to [Brent Ozar's Stack Overflow Database](https://www.brentozar.com/archive/2015/10/how-to-download-the-stack-overflow-database-via-bittorrent/) for download instructions.\n\n### Loading the Database\n\n1. After downloading, extract the database files.\n2. Attach the database files to your SQL Server instance.\n3. Configure any necessary server settings or file paths as required.\n\n## Database Schema\n\nThe Stack Overflow database includes tables such as Users, Posts, Comments, and Votes. These tables contain various fields related to Stack Overflow activity.\n\n## Queries - [queries](queries.sql)\n\n### Query 1 - [query01](query/query01.sql)\n\nRetrieves the DisplayName, Location, and Reputation of users from the Users table, ordered by Reputation in descending order.\n\u003cbr\u003e\n\u003cstrong\u003e[csv](https://raw.githubusercontent.com/lnvaldez/stackoverflow-sql/main/data/csv/data1.csv)\u003c/strong\u003e\n\n### Query 2 - [query02](query/query02.sql)\n\nRetrieves the Title of posts and the DisplayName of users who authored those posts, filtering out posts where Title is not null.\n\u003cbr\u003e\n\u003cstrong\u003e[csv](https://raw.githubusercontent.com/lnvaldez/stackoverflow-sql/main/data/csv/data2.csv)\u003c/strong\u003e\n\n### Query 3 - [query03](query/query03.sql)\n\nCalculates the average Score of posts authored by each user (DisplayName), sorting users by their average score in descending order.\n\u003cbr\u003e\n\u003cstrong\u003e[csv](https://raw.githubusercontent.com/lnvaldez/stackoverflow-sql/main/data/csv/data3.csv)\u003c/strong\u003e\n\n### Query 4 - [query04](query/query04.sql)\n\nRetrieves the DisplayName of users who have made more than 100 comments in total.\n\u003cbr\u003e\n\u003cstrong\u003e[csv](data/csv/data4.csv)\u003c/strong\u003e\n\n### Query 5 - [query05](query/query05.sql)\n\nUpdates the Location column of users to 'Desconocido' (Unknown in Spanish) where Location is null or empty.\n\u003cbr\u003e\n\u003cstrong\u003e[csv](https://raw.githubusercontent.com/lnvaldez/stackoverflow-sql/main/data/csv/data5.csv) / [rpt](data/rpt/report5.rpt)\u003c/strong\u003e\n\n### Query 6 - [query06](query/query06.sql)\n\nDeletes comments made by users whose Reputation is less than 100, displaying the number of deleted comments after execution.\n\u003cbr\u003e\n\u003cstrong\u003e[rpt](data/rpt/report6.rpt)\u003c/strong\u003e\n\n### Query 7 - [query07](query/query07.sql)\n\nRetrieves DisplayName of users along with the total count of their posts (TotalPosts), comments (TotalComments), and badges (TotalBadges).\n\u003cbr\u003e\n\u003cstrong\u003e[csv](https://raw.githubusercontent.com/lnvaldez/stackoverflow-sql-queries/main/data/csv/data7.csv)\u003c/strong\u003e\n\n### Query 8 - [query08](query/query08.sql)\n\nRetrieves the top 10 posts by Title and Score from the Posts table, ordered by Score in descending order.\n\u003cbr\u003e\n\u003cstrong\u003e[csv](data/csv/data8.csv)\u003c/strong\u003e\n\n### Query 9 - [query09](query/query09.sql)\n\nRetrieves the most recent 5 comments with their Text and CreationDate from the Comments table, ordered by CreationDate in descending order.\n\u003cbr\u003e\n\u003cstrong\u003e[csv](data/csv/data9.csv)\u003c/strong\u003e\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flnvaldez%2Fstackoverflow-sql-queries","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flnvaldez%2Fstackoverflow-sql-queries","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flnvaldez%2Fstackoverflow-sql-queries/lists"}