Created
May 27, 2025 02:47
-
-
Save tbbooher/a4314d79776a386661b5d27a20a91530 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
'id' AS column_name, | |
COUNT(id) AS populated_count, | |
(COUNT(*) - COUNT(id)) AS missing_count, | |
COUNT(*) AS total_rows, | |
ROUND((COUNT(id)::DECIMAL * 100 / COUNT(*)), 2) AS percentage_populated | |
FROM bike_listings_new | |
UNION ALL | |
SELECT | |
'city' AS column_name, | |
COUNT(city) AS populated_count, | |
(COUNT(*) - COUNT(city)) AS missing_count, | |
COUNT(*) AS total_rows, | |
ROUND((COUNT(city)::DECIMAL * 100 / COUNT(*)), 2) AS percentage_populated | |
FROM bike_listings_new | |
UNION ALL | |
SELECT | |
'post_date' AS column_name, | |
COUNT(post_date) AS populated_count, | |
(COUNT(*) - COUNT(post_date)) AS missing_count, | |
COUNT(*) AS total_rows, | |
ROUND((COUNT(post_date)::DECIMAL * 100 / COUNT(*)), 2) AS percentage_populated | |
FROM bike_listings_new | |
UNION ALL | |
SELECT | |
'price' AS column_name, | |
COUNT(price) AS populated_count, | |
(COUNT(*) - COUNT(price)) AS missing_count, | |
COUNT(*) AS total_rows, | |
ROUND((COUNT(price)::DECIMAL * 100 / COUNT(*)), 2) AS percentage_populated | |
FROM bike_listings_new | |
UNION ALL | |
SELECT | |
'currency' AS column_name, | |
COUNT(currency) AS populated_count, | |
(COUNT(*) - COUNT(currency)) AS missing_count, | |
COUNT(*) AS total_rows, | |
ROUND((COUNT(currency)::DECIMAL * 100 / COUNT(*)), 2) AS percentage_populated | |
FROM bike_listings_new | |
UNION ALL | |
SELECT | |
'title' AS column_name, | |
COUNT(title) AS populated_count, | |
(COUNT(*) - COUNT(title)) AS missing_count, | |
COUNT(*) AS total_rows, | |
ROUND((COUNT(title)::DECIMAL * 100 / COUNT(*)), 2) AS percentage_populated | |
FROM bike_listings_new | |
UNION ALL | |
SELECT | |
'url' AS column_name, | |
COUNT(url) AS populated_count, | |
(COUNT(*) - COUNT(url)) AS missing_count, | |
COUNT(*) AS total_rows, | |
ROUND((COUNT(url)::DECIMAL * 100 / COUNT(*)), 2) AS percentage_populated | |
FROM bike_listings_new | |
UNION ALL | |
SELECT | |
'location' AS column_name, | |
COUNT(location) AS populated_count, | |
(COUNT(*) - COUNT(location)) AS missing_count, | |
COUNT(*) AS total_rows, | |
ROUND((COUNT(location)::DECIMAL * 100 / COUNT(*)), 2) AS percentage_populated | |
FROM bike_listings_new | |
UNION ALL | |
SELECT | |
'year' AS column_name, | |
COUNT(year) AS populated_count, | |
(COUNT(*) - COUNT(year)) AS missing_count, | |
COUNT(*) AS total_rows, | |
ROUND((COUNT(year)::DECIMAL * 100 / COUNT(*)), 2) AS percentage_populated | |
FROM bike_listings_new | |
UNION ALL | |
SELECT | |
'brand' AS column_name, | |
COUNT(brand) AS populated_count, | |
(COUNT(*) - COUNT(brand)) AS missing_count, | |
COUNT(*) AS total_rows, | |
ROUND((COUNT(brand)::DECIMAL * 100 / COUNT(*)), 2) AS percentage_populated | |
FROM bike_listings_new | |
UNION ALL | |
SELECT | |
'original_model' AS column_name, | |
COUNT(original_model) AS populated_count, | |
(COUNT(*) - COUNT(original_model)) AS missing_count, | |
COUNT(*) AS total_rows, | |
ROUND((COUNT(original_model)::DECIMAL * 100 / COUNT(*)), 2) AS percentage_populated | |
FROM bike_listings_new | |
UNION ALL | |
SELECT | |
'model' AS column_name, | |
COUNT(model) AS populated_count, | |
(COUNT(*) - COUNT(model)) AS missing_count, | |
COUNT(*) AS total_rows, | |
ROUND((COUNT(model)::DECIMAL * 100 / COUNT(*)), 2) AS percentage_populated | |
FROM bike_listings_new | |
UNION ALL | |
SELECT | |
'frame_material' AS column_name, | |
COUNT(frame_material) AS populated_count, | |
(COUNT(*) - COUNT(frame_material)) AS missing_count, | |
COUNT(*) AS total_rows, | |
ROUND((COUNT(frame_material)::DECIMAL * 100 / COUNT(*)), 2) AS percentage_populated | |
FROM bike_listings_new | |
UNION ALL | |
SELECT | |
'wheel_size' AS column_name, | |
COUNT(wheel_size) AS populated_count, | |
(COUNT(*) - COUNT(wheel_size)) AS missing_count, | |
COUNT(*) AS total_rows, | |
ROUND((COUNT(wheel_size)::DECIMAL * 100 / COUNT(*)), 2) AS percentage_populated | |
FROM bike_listings_new | |
UNION ALL | |
SELECT | |
'drivetrain' AS column_name, | |
COUNT(drivetrain) AS populated_count, | |
(COUNT(*) - COUNT(drivetrain)) AS missing_count, | |
COUNT(*) AS total_rows, | |
ROUND((COUNT(drivetrain)::DECIMAL * 100 / COUNT(*)), 2) AS percentage_populated | |
FROM bike_listings_new | |
UNION ALL | |
SELECT | |
'brake_type' AS column_name, | |
COUNT(brake_type) AS populated_count, | |
(COUNT(*) - COUNT(brake_type)) AS missing_count, | |
COUNT(*) AS total_rows, | |
ROUND((COUNT(brake_type)::DECIMAL * 100 / COUNT(*)), 2) AS percentage_populated | |
FROM bike_listings_new | |
UNION ALL | |
SELECT | |
'suspension' AS column_name, | |
COUNT(suspension) AS populated_count, | |
(COUNT(*) - COUNT(suspension)) AS missing_count, | |
COUNT(*) AS total_rows, | |
ROUND((COUNT(suspension)::DECIMAL * 100 / COUNT(*)), 2) AS percentage_populated | |
FROM bike_listings_new | |
UNION ALL | |
SELECT | |
'scraped_at' AS column_name, | |
COUNT(scraped_at) AS populated_count, | |
(COUNT(*) - COUNT(scraped_at)) AS missing_count, | |
COUNT(*) AS total_rows, | |
ROUND((COUNT(scraped_at)::DECIMAL * 100 / COUNT(*)), 2) AS percentage_populated | |
FROM bike_listings_new | |
UNION ALL | |
SELECT | |
'tire_brand' AS column_name, | |
COUNT(tire_brand) AS populated_count, | |
(COUNT(*) - COUNT(tire_brand)) AS missing_count, | |
COUNT(*) AS total_rows, | |
ROUND((COUNT(tire_brand)::DECIMAL * 100 / COUNT(*)), 2) AS percentage_populated | |
FROM bike_listings_new | |
UNION ALL | |
SELECT | |
'frame_size' AS column_name, | |
COUNT(frame_size) AS populated_count, | |
(COUNT(*) - COUNT(frame_size)) AS missing_count, | |
COUNT(*) AS total_rows, | |
ROUND((COUNT(frame_size)::DECIMAL * 100 / COUNT(*)), 2) AS percentage_populated | |
FROM bike_listings_new | |
UNION ALL | |
SELECT | |
'travel' AS column_name, | |
COUNT(travel) AS populated_count, | |
(COUNT(*) - COUNT(travel)) AS missing_count, | |
COUNT(*) AS total_rows, | |
ROUND((COUNT(travel)::DECIMAL * 100 / COUNT(*)), 2) AS percentage_populated | |
FROM bike_listings_new | |
UNION ALL | |
SELECT | |
'source' AS column_name, | |
COUNT(source) AS populated_count, | |
(COUNT(*) - COUNT(source)) AS missing_count, | |
COUNT(*) AS total_rows, | |
ROUND((COUNT(source)::DECIMAL * 100 / COUNT(*)), 2) AS percentage_populated | |
FROM bike_listings_new | |
ORDER BY | |
percentage_populated DESC; -- or ORDER BY missing_count DESC; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment