Q&A for spacecraft operators, scientists, engineers, and enthusiasts
SELECT * FROM Posts ORDER BY FavoriteCount DESC; -- Question 3 -- Using the Posts and PostType tables, find the average number of -- Favorites per post for each post type. Once again, -- please note something interesting this query tells you about the -- database below your code. SELECT Top 100 COUNT(*) my_count, pt.Id post_type_id, pt.Name post_type_name, SUM(p.FavoriteCount) sum_fvt, AVG(p.FavoriteCount) avg_fvt FROM Posts p LEFT JOIN PostTypes pt ON p.PostTypeId = pt.Id GROUP BY pt.Id, pt.Name ORDER BY 1 DESC ; -- Question 2 -- Using the Users table, please query the 25 most frequent -- “Reputation” values users have on the site. --Please comment below your code something interesting this -- result tells you about the “Reputation” field. --SELECT TOP 25 COUNT(*), Reputation FROM Users GROUP BY Reputation ORDER BY 1 DESC; -- The most commonly occuring reputation scores have 1s and 0s only? -- Question 1 --SELECT COUNT(DISTINCT(OwnerUserId)) FROM Posts; --SELECT COUNT(DISTINCT(OwnerUserId)) FROM Posts WHERE OwnerUserId >=0;