SQL to create histograms (wishli.st)

6 points by coldclimate ↗ HN
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

3 comments

[ 5.1 ms ] story [ 17.9 ms ] thread
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.

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 )