Raw real estate transactional records often suffer from missing fields, inconsistent formatting, embedded delimited strings, and duplicate entries that prevent accurate market analysis. This project answers:
- How can raw real estate datasets be systematically standardized and cleaned in SQL Server for downstream analytics and reporting?
- How can missing property addresses be accurately populated using relational self-joins on parcel identifiers?
- How can unstructured address strings be split into structured, queryable relational attributes (
Address,City,State)?
The dataset contains raw historical housing market sales records from Nashville, Tennessee.
Public & Real. Public housing sales data extracted for real estate analytics benchmarking.
- Record Count: ~56,000 property sale records.
- Time Period: Historical residential property sales transactions.
- Database Management System: Microsoft SQL Server / T-SQL (SQL Server Management Studio).
- Key SQL Techniques: String Manipulation (
SUBSTRING,CHARINDEX,PARSENAME), Self-Joins (ISNULL), Conditional Logic (CASE), Window Functions (ROW_NUMBER()), Common Table Expressions (CTEs), and DDL Statements (ALTER TABLE,DROP COLUMN).
- Date Standardization: Converted unformatted
DateTimevalues into a standardizedDateformat usingCONVERT(). - Missing Address Imputation: Performed a self-join matching on
ParcelIDto populate missingPropertyAddressvalues whereUniqueIDdiffered. - Address Delimiter Parsing:
- Parsed
PropertyAddressintoPropertySplitAddressandPropertySplitCityusingSUBSTRINGandCHARINDEX. - Parsed
OwnerAddressintoOwnerSplitAddress,OwnerSplitCity, andOwnerSplitStateusingPARSENAMEandREPLACE.
- Parsed
- Categorical Value Normalization: Standardized the
SoldAsVacantbinary column by converting inconsistent'Y'/'N'values into uniform'Yes'/'No'strings. - Deduplication: Utilized a CTE with
ROW_NUMBER() OVER(PARTITION BY ...)to identify and remove duplicate rows across matching parcel, address, price, and date keys. - Column Cleanup: Dropped redundant and unformatted staging columns (
PropertyAddress,OwnerAddress,TaxDistrict,SaleDate).
- Checked
NULLcounts onPropertyAddresspre- and post-join to ensure 100% address resolution. - Executed
DISTINCT(SoldAsVacant)queries to confirm only'Yes'and'No'values remained. - Ran verification queries on
ROW_NUMBER()outputs to confirm zero duplicate record keys remained in the final dataset.
- Over 100+ property records had missing address fields that were successfully recovered through
ParcelIDself-joins. - Identified and deleted duplicate rows that would have skewed average sales price calculations in market analysis.
- Downstream analysts can now execute reliable neighborhood price-per-square-foot aggregations without string parsing overhead.
- Cleansed dataset can be directly ingested into BI platforms (Power BI/Tableau) without requiring complex ETL transformations on load.
- Transformations were executed directly in a SQL Server staging table; in a production data warehouse setting, transformations would be executed within dedicated staging views or orchestration pipelines.
- Clone this repository:
git clone [https://github.com/your-username/sql-data-cleaning.git](https://github.com/your-username/sql-data-cleaning.git)