Saturday, February 25, 2012

Looking for method to create stem and leaf graph

All,

I would appreciate any advice anyone might have to offer on how to approach creating a stem-and-leaf graph using t-sql. My table structure is as follows:

CREATE TABLE [dbo].[Responses](
[appraisalId] [char](9) NOT NULL,
[userId] [char](9) NOT NULL,
[res1] [decimal](5, 2) NOT NULL,
[res2] [decimal](5, 2) NOT NULL,
[res3] [decimal](5, 3) NOT NULL,
[res4] [decimal](5, 2) NOT NULL,
[res5] [decimal](5, 2) NOT NULL,
CONSTRAINT [PK_Responses] PRIMARY KEY CLUSTERED
(
[appraisalId] ASC,
[userId] ASC
))

ALTER TABLE [dbo].[Responses] WITH CHECK ADD CONSTRAINT [CK_Responses_res1] CHECK (([res1]>=(1) AND [res1]<=(5)))
ALTER TABLE [dbo].[Responses] WITH CHECK ADD CONSTRAINT [CK_Responses_res2] CHECK (([res2]>=(1) AND [res2]<=(5)))
ALTER TABLE [dbo].[Responses] WITH CHECK ADD CONSTRAINT [CK_Responses_res3] CHECK (([res3]>=(1) AND [res3]<=(5)))
ALTER TABLE [dbo].[Responses] WITH CHECK ADD CONSTRAINT [CK_Responses_res4] CHECK (([res4]>=(1) AND [res4]<=(5)))
ALTER TABLE [dbo].[Responses] WITH CHECK ADD CONSTRAINT [CK_Responses_res5] CHECK (([res5]>=(1) AND [res5]<=(5)))

The problem to be solved is to create a stem and leaf graph that shows for each response value column res1 to res5, with valid values 1.0 - 5.0, create a graph similar to the following:

5|11233445567789
4|12233445566789
3|11334556667789
2|11223444567889
1|12233345556778

It was my hope that I could do this using reporting services, but I'll almost settle for being able to produce a two column result set similar to the above.

Best,
Steven

Please post some sample data (input) & expected sample output data.

It will help us to understand the problem quickly.. Smile

|||I believe at this point I've come up with a solution that will work. Perhaps the task of just writing down here what little bit I did helped me to think more clearly about the problem to solve.

I was playing around with a stacked bar chart, and experimented with a custom fill, and wound up with something that actually looks quite like what I wanted.

Thanks for the assist!

Best,
B.

No comments:

Post a Comment