29Jul/098
Poor (Wo)Man’s Graph
Lary shared this poor (wo)man's graph with me today, and I thought it was pretty awesome:
Select OrderDate , COUNT(*) As 'orders' , REPLICATE('=', COUNT(*)) As 'orderGraph' , SUM(TotalDue) As 'revenue' , REPLICATE('$', SUM(TotalDue)/1000) As 'revenueGraph' From AdventureWorks.Sales.SalesOrderHeader Where OrderDate Between '2003-07-15' And '2003-07-31' Group By OrderDate Order By OrderDate;
This will return a simple but effective "graph" for you:
orderDate orders orderGraph revenue revenueGraph ---------- ------ ------------------------------ -------- ---------------------------------------- 2003-07-15 19 =================== 34025.24 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ 2003-07-16 14 ============== 26687.65 $$$$$$$$$$$$$$$$$$$$$$$$$$$ 2003-07-17 16 ================ 32411.93 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ 2003-07-18 9 ========= 18634.91 $$$$$$$$$$$$$$$$$$$ 2003-07-19 13 ============= 19603.23 $$$$$$$$$$$$$$$$$$$$ 2003-07-20 24 ======================== 47522.80 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ 2003-07-21 9 ========= 11781.62 $$$$$$$$$$$$ 2003-07-22 17 ================= 32322.50 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ 2003-07-23 15 =============== 30906.44 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ 2003-07-24 28 ============================ 51107.90 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ 2003-07-25 15 =============== 27058.10 $$$$$$$$$$$$$$$$$$$$$$$$$$$ 2003-07-26 18 ================== 41076.49 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ 2003-07-27 15 =============== 22169.88 $$$$$$$$$$$$$$$$$$$$$$ 2003-07-28 16 ================ 23945.80 $$$$$$$$$$$$$$$$$$$$$$$$ 2003-07-29 25 ========================= 51122.95 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ 2003-07-30 12 ============ 23476.44 $$$$$$$$$$$$$$$$$$$$$$$ 2003-07-31 18 ================== 36266.76 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
Who needs Reporting Services when you've got REPLICATE?
Tagged as: tips, TSQL
Leave a comment
Categories
- Business Intelligence
- Internals
- Miscellaneous
- PASS
- Performance & Tuning
- Presentations
- SQL 2008
- SQL Tips
- Syndication
- T-SQL Scripts
Subscribe to my blog!
| Like what you see? Subscribe! |
![]() |
Around the Web
Recent Tweets
- RT @Phil_Factor: SQL Server table columns under the hood http://t.co/vp7gQ77B < what a great post
- @tradney haha that's awesome :)
- OH: @AdamMachanic's #sqlpass session was one of the best I've ever seen.
Archives
- November 2011
- October 2011
- September 2011
- July 2011
- June 2011
- May 2011
- April 2011
- January 2011
- December 2010
- November 2010
- October 2010
- September 2010
- July 2010
- June 2010
- May 2010
- April 2010
- February 2010
- January 2010
- November 2009
- October 2009
- September 2009
- August 2009
- July 2009
- June 2009
- May 2009
- April 2009
- March 2009
- February 2009
- January 2009
- December 2008
- November 2008
- October 2008



August 1st, 2009 - 23:56
Nice, very creative.
August 3rd, 2009 - 14:42
Whoever wrote this must be a genius!!
August 3rd, 2009 - 15:51
nice, keep up the good work!!!
August 10th, 2009 - 10:34
Great. Really I laughed. Nice Work!
August 14th, 2009 - 10:54
Ha ha ha this is awesome! I love it. Old school effectiveness without the new school bloat! Simply cool!
Manuel
August 14th, 2009 - 13:22
You have induced flashbacks to COBOL, FORTRAN, and GECOS assmbler in this decrepit old codger’s mind.
We used to do things like this because it was “the only way…” %)
August 18th, 2009 - 09:15
Wow, that’s ingenious! I love it.
August 26th, 2009 - 18:10
This tip is vastly underutilized. I believe I first learned of it in the late, great Ken Henderson Guru’s Guide. Thanks for sharing, Michelle!