Hacker News new | ask | show | jobs
SQL to create histograms (wishli.st)
6 points by coldclimate 5869 days ago
There's nothing really complicated about it, but I didn't find a good example online anywhere, so when I figured it out, it was time to share it
2 comments

A little flaky perhaps, but if you're gonna love sql :-)

select distinct cnt, count(cnt) over (partition by cnt) from (

select 'a' usr,1 cnt from dual union select 'b' usr,1 cnt from dual union select 'c' usr,2 cnt from dual union select 'd' usr,3 cnt from dual union select 'e' usr,3 cnt from dual )

Something tells me that query would probably run faster if written as a join, especially in MySQL.

Also, what's the point of a section of the same content in the article being repeated in a larger font to the left?

Hmm, you're right it would probably run a bit faster as a JOIN, I just default to using subqueries by nature.

Re:Theme with massive paragraph - it was based on a magazine wordpress theme and we're yet to edit it down.