<< back to blog

SQL SparkLines

software ~ sql ~ gui ~ design

28 Feb, 2008

I recently blogged about a technique for generating charts in your raw SQL. It occurred to me that these are a little bit like SparkLines. So, I’m calling them SQL Sparklines for now!

According to Tufte, attaining a high data/ink ratio is a good measure of effective communication. So here’s another attempt using less ink, and also showing some more data.

Comparing Uses who registered on a site, to those that actually confirmed their registration

SQL Sparklines

See the a raise in the bar to show where the value falls on the scale? This is possible using the SQL Stuff statement. See below:

HTML parse error: 
<pre>
select 
	Convert(varchar(12),DateCreated,102) as Date, 
	cast(count(DateConfirmed) as varchar(4)) + '/' + cast(count(DateCreated) as varchar(4)) as [C/R],		
	cast(stuff(replace(space(count(DateCreated)),' ','_'),count(DateConfirmed),1,'-') as varchar(50)) as Chart
from 
	Operators
where 
	DATEDIFF(day, DateCreated, GETDATE()) < 60
group by 
	Convert(varchar(12),DateCreated,102)
order by 
	1 desc
</pre>

I’ve used ISO date formatting to get a good text sort order.

The new version (above) of the chart is less pretty than the old one (below), but is it more effective at communicating? I’m not sure!

The Original Bar Chart Version

SQL Sparklines Bar Chart

T

You may also like...
Man makes nice software. Sells it. Makes $100,000 in 5 months
TODO.txt 2008 Ultimate Team Edition
Pretty Simple Software
Loose Coupling: Quote de jour
Cheap as Chips private Git hosting
Putting Git in the cloud with Amazon S3
Friendliest console installer EVER!
What Open Source stack do the gurus use?
Nice use of Google maps in registration
Generate State Machine diagrams from your POCO Entities

kick it on DotNetKicks.com
blog comments powered by Disqus