October 8, 2008 at 2:53 am
Greg, forgive me for posting wrong code.
Please find the correct code.
CREATE TABLE dbo.mgr_calc
(
sID varchar(15) NOT NULL,
sPform varchar(10) NOT NULL,
AsOfDate datetime NOT NULL,
oney_gross float NULL,
one_yr_ann_std_dev float NULL,
one_yr_sharpe_ratio float NULL,
one_yr_up_capture float NULL,
one_yr_down_capture float NULL,
one_yr_downside_dev float NULL,
one_yr_ann_tracking_error float NULL,
one_yr_info_ratio float NULL,
one_yr_batt_avg float NULL,
threey_gross float NULL,
three_yr_ann_std_dev float NULL,
three_yr_sharpe_ratio float NULL,
three_yr_up_capture float NULL,
three_yr_down_capture float NULL,
three_yr_downside_dev float NULL,
three_yr_ann_tracking_error float NULL,
three_yr_info_ratio float NULL,
three_yr_batt_avg float NULL,
fivey_gross float NULL,
five_yr_ann_std_dev float NULL,
five_yr_sharpe_ratio float NULL,
five_yr_up_capture float NULL,
five_yr_down_capture float NULL,
five_yr_downside_dev float NULL,
five_yr_ann_tracking_error float NULL,
five_yr_info_ratio float NULL,
five_yr_batt_avg float NULL,
CONSTRAINT mgr_pe_6233933402
PRIMARY KEY CLUSTERED (sID,sPform,AsOfDate)
)
insert into mgr_calc
Select '1X54321','Custom',getdate(),0,2,4,5.8,1.7,2,2,1,0.982,0.45,0.69142,0.5228,0.354,0.00321,2,0.01714,-0.1514,-0.319999,-0.48857,-0.65714,-0.82571,2,3,4,5,7,0.1001
union all
select '1X54322','Custom',getdate(),0,2,4,5.9,3.9,2,1,1,0.8921,2,0.6914,0.52285,0.35428,0.0124,1,0.01714,-0.151428,-0.31999,-0.48857,-0.65714,-0.8249,5,2,1,4,6,0.45632
karthik
October 8, 2008 at 3:03 am
The way you did it is fine, Karthik... only change I would make is to change all the UNION's into UNION ALL for performance and data integrity reasons. UNION does a DISTINCT and that could blow away some of your data.
Jeff,
Thanks for your suggestion.
Actually i initially used UNION ALL only. But the result was not in the sorted order.
i.e
1X43521 0.445
1X43522 1
1X43521 -1.344
1X43522 2.5
.
.
.
I got the results like above. As i want to split the values as
1X43521 0.445 1X43522 1
1X43521 -1.344 1X43522 2.5
I felt that the first result set won't help me to get the above result set. Thats why i used UNION.
Please let me know the alternate way to achieve my requirement. Also can you help me to get the expected result ?
karthik
October 8, 2008 at 6:19 am
UNION will disappoint you because it will be slow and it will blow away data, in this case, quite unexpectedly. If you want the output in sorted order, you have to divide and conquer. Use the SELECT/UNION ALL stuff to "unpivot" the data and add an ORDER BY at the end after the last Select. There can only be one ORDER BY for a SELECT/UNION ALL and it will affect the whole thing.
If you want each SELECT in the UNION ALL to be sorted, then you either have to add a hardcoded "sort" column (usually an integer) to the SELECT/UNION ALL, or you have to have something unique per Select that will cause the correct sort order when you sort on either.
--Jeff Moden
Change is inevitable... Change for the better is not.
October 8, 2008 at 6:31 am
Jeff,
Actually i have used your first method to sort the data.
SELECT/UNION ALL and and ORDER BY clause in the last select. It works fine.
Can you help me to get the expected result ?
i.e
1X54321 0
1X54321 0.01714
1X54321 0.1
1X54321 0.185
1X54321 0.354
1X54321 0.5228
1X54321 0.69142
1X54321 0.86
1X54321 1
1X54321 1.3
1X54321 1.4
1X54321 3
1X54321 -0.1514
1X54321 -0.319999
1X54321 -0.48857
1X54321 -0.65714
1X54321 -0.82571
1X43522 0
1X43522 0.01714
1X43522 0.18571
1X43522 0.35428
1X43522 0.52285
1X43522 0.6914
1X43522 0.86
1X43522 1
1X43522 1.3
1X43522 1.4
1X43522 3
1X43522 -0.151428
1X43522 -0.31999
1X43522 -0.48857
1X43522 -0.65714
1X43522 -0.8249
i need to split it as below
Expected output:
1X54321 0 1X43522 0
1X54321 0.01714 1X43522 0.01714
1X54321 0.1 1X43522 0.18571
1X54321 0.185 1X43522 0.35428
1X54321 0.354 1X43522 0.52285
1X54321 0.5228 1X43522 0.6914
1X54321 0.69142 1X43522 0.86
1X54321 0.86 1X43522 1
1X54321 1 1X43522 1.3
1X54321 1.3 1X43522 1.4
1X54321 1.4 1X43522 3
1X54321 3 1X43522 -0.151428
1X54321 -0.1514 1X43522 -0.31999
1X54321 -0.319999 1X43522 -0.48857
1X54321 -0.48857 1X43522 -0.65714
1X54321 -0.65714 1X43522 -0.8249
1X54321 -0.82571
Here the problem is i dont know the number of manager id's. It may be 3 or 4 or more than that.
if it is 3, i have to split it like
1x54321 0.4455 1x54322 2.545 1x54323 5.232
. . .
. . .
. . .
karthik
October 8, 2008 at 7:39 am
Here's how to do it with UNPIVOT.
Please note that I only used part of the table definition for this example.
CREATE TABLE #mgr_calc
(
sID varchar(15) NOT NULL,
sPform varchar(10) NOT NULL,
AsOfDate datetime NOT NULL,
oney_gross float NULL,
one_yr_ann_std_dev float NULL,
one_yr_sharpe_ratio float NULL,
one_yr_up_capture float NULL,
one_yr_down_capture float NULL,
one_yr_downside_dev float NULL,
one_yr_ann_tracking_error float NULL,
one_yr_info_ratio float NULL,
one_yr_batt_avg float NULL,
-- threey_gross float NULL,
-- three_yr_ann_std_dev float NULL,
-- three_yr_sharpe_ratio float NULL,
-- three_yr_up_capture float NULL,
-- three_yr_down_capture float NULL,
-- three_yr_downside_dev float NULL,
-- three_yr_ann_tracking_error float NULL,
-- three_yr_info_ratio float NULL,
-- three_yr_batt_avg float NULL,
-- fivey_gross float NULL,
-- five_yr_ann_std_dev float NULL,
-- five_yr_sharpe_ratio float NULL,
-- five_yr_up_capture float NULL,
-- five_yr_down_capture float NULL,
-- five_yr_downside_dev float NULL,
-- five_yr_ann_tracking_error float NULL,
-- five_yr_info_ratio float NULL,
-- five_yr_batt_avg float NULL,
)
insert into #mgr_calc
Select '1X54321','Custom',getdate(),0,2,4,5.8,1.7,2,2,1,0.982--,0.45,0.69142,0.5228,0.354,0.00321,2,0.01714,-0.1514,-0.319999,-0.48857,-0.65714,-0.82571,2,3,4,5,7,0.1001
union all
select '1X54322','Custom',getdate(),0,2,4,5.9,3.9,2,1,1,0.8921--,2,0.6914,0.52285,0.35428,0.0124,1,0.01714,-0.151428,-0.31999,-0.48857,-0.65714,-0.8249,5,2,1,4,6,0.45632
SELECT SID
, [Value]
, [Type]
FROM
(
SELECT *
FROM #mgr_calc
) S
UNPIVOT
(
[Value]
FOR [Type] IN (
[oney_gross]
,[one_yr_ann_std_dev]
,[one_yr_sharpe_ratio]
,[one_yr_up_capture]
,[one_yr_downside_dev]
,[one_yr_ann_tracking_error]
,[one_yr_info_ratio]
, [one_yr_batt_avg]
)
) AS U
drop table #mgr_calc
October 8, 2008 at 8:19 am
I don't have 2005, so I could not try UNPIVOT, but it sure looks a lot better than my solution. Anyhow, I made a temp table with the column names, and, of course, the whole thing relies on hard coding the values. The biggest problem I see is that the addition or deletion of managers will be a royal PITA.
--Create a temp table to hold all the records, with the addition
--of a hard coded column name for use in the queries
IF OBJECT_ID('TempDB..#mgr_calc_columns','u') IS NOT NULL
DROP TABLE #mgr_calc_columns
SELECT
*
INTO #mgr_calc_columns
FROM
(
SELECT sID,ISNULL(oney_gross,0) AS VALUE,'oney_gross' AS COL_NM FROM #mgr_calc UNION ALL
SELECT sID,ISNULL(one_yr_ann_std_dev,0) AS VALUE, 'one_yr_ann_std_dev' AS COL_NM FROM #mgr_calc UNION ALL
SELECT sID,ISNULL(one_yr_sharpe_ratio,0) AS VALUE, 'one_yr_sharpe_ratio' AS COL_NM FROM #mgr_calc UNION ALL
SELECT sID,ISNULL(one_yr_up_capture,0) AS VALUE,'one_yr_up_capture' AS COL_NM FROM #mgr_calc UNION ALL
SELECT sID,ISNULL(one_yr_down_capture,0) AS VALUE,'one_yr_down_capture' AS COL_NM FROM #mgr_calc UNION ALL
SELECT sID,ISNULL(one_yr_downside_dev,0) AS VALUE,'one_yr_downside_dev' AS COL_NM FROM #mgr_calc UNION ALL
SELECT sID,ISNULL(one_yr_ann_tracking_error,0) AS VALUE, 'one_yr_ann_tracking_error' AS COL_NM FROM #mgr_calc UNION ALL
SELECT sID,ISNULL(one_yr_info_ratio,0) AS VALUE, 'one_yr_info_ratio' AS COL_NM FROM #mgr_calc UNION ALL
SELECT sID,ISNULL(one_yr_batt_avg,0) AS VALUE, 'one_yr_batt_avg' AS COL_NM FROM #mgr_calc UNION ALL
SELECT sID,ISNULL(threey_gross,0) AS VALUE,'threey_gross' AS COL_NM FROM #mgr_calc UNION ALL
SELECT sID,ISNULL(three_yr_ann_std_dev,0) AS VALUE, 'three_yr_ann_std_dev' AS COL_NM FROM #mgr_calc UNION ALL
SELECT sID,ISNULL(three_yr_sharpe_ratio,0) AS VALUE, 'three_yr_sharpe_ratio' AS COL_NM FROM #mgr_calc UNION ALL
SELECT sID,ISNULL(three_yr_up_capture,0) AS VALUE,'three_yr_up_capture' AS COL_NM FROM #mgr_calc UNION ALL
SELECT sID,ISNULL(three_yr_down_capture,0) AS VALUE,'three_yr_down_capture' AS COL_NM FROM #mgr_calc UNION ALL
SELECT sID,ISNULL(three_yr_downside_dev,0) AS VALUE,'three_yr_downside_dev' AS COL_NM FROM #mgr_calc UNION ALL
SELECT sID,ISNULL(three_yr_ann_tracking_error,0) AS VALUE, 'three_yr_ann_tracking_error' AS COL_NM FROM #mgr_calc UNION ALL
SELECT sID,ISNULL(three_yr_info_ratio,0) AS VALUE, 'three_yr_info_ratio' AS COL_NM FROM #mgr_calc UNION ALL
SELECT sID,ISNULL(three_yr_batt_avg,0) AS VALUE, 'three_yr_batt_avg' AS COL_NM FROM #mgr_calc UNION ALL
SELECT sID,ISNULL(fivey_gross,0) AS VALUE,'fivey_gross' AS COL_NM FROM #mgr_calc UNION ALL
SELECT sID,ISNULL(five_yr_ann_std_dev,0) AS VALUE, 'five_yr_ann_std_dev' AS COL_NM FROM #mgr_calc UNION ALL
SELECT sID,ISNULL(five_yr_sharpe_ratio,0) AS VALUE, 'five_yr_sharpe_ratio' AS COL_NM FROM #mgr_calc UNION ALL
SELECT sID,ISNULL(five_yr_up_capture,0) AS VALUE,'five_yr_up_capture' AS COL_NM FROM #mgr_calc UNION ALL
SELECT sID,ISNULL(five_yr_down_capture,0) AS VALUE,'five_yr_down_capture' AS COL_NM FROM #mgr_calc UNION ALL
SELECT sID,ISNULL(five_yr_downside_dev,0) AS VALUE,'five_yr_downside_dev' AS COL_NM FROM #mgr_calc UNION ALL
SELECT sID,ISNULL(five_yr_ann_tracking_error,0) AS VALUE, 'five_yr_ann_tracking_error' AS COL_NM FROM #mgr_calc UNION ALL
SELECT sID,ISNULL(five_yr_info_ratio,0) AS VALUE, 'five_yr_info_ratio' AS COL_NM FROM #mgr_calc UNION ALL
SELECT sID,ISNULL(five_yr_batt_avg,0) AS VALUE, 'five_yr_batt_avg' AS COL_NM FROM #mgr_calc
) t1
--Display the results
--Use the column name and manager ID
SELECT
'oney_gross' AS Mearurement,
SUM(CASE WHEN sID = '1X54321' AND col_nm = 'oney_gross' THEN value END) AS Mgr_1,
SUM(CASE WHEN sID = '1X54322' AND col_nm = 'oney_gross' THEN value END) AS Mgr_2
FROM #mgr_calc_columns
UNION ALL
SELECT
'one_yr_ann_std_dev' AS Mearurement,
SUM(CASE WHEN sID = '1X54321' AND col_nm = 'one_yr_ann_std_dev' THEN value END) AS Mgr_1,
SUM(CASE WHEN sID = '1X54322' AND col_nm = 'one_yr_ann_std_dev' THEN value END) AS Mgr_2
FROM #mgr_calc_columns
UNION ALL
SELECT
'one_yr_sharpe_ratio' AS Mearurement,
SUM(CASE WHEN sID = '1X54321' AND col_nm = 'one_yr_sharpe_ratio' THEN value END) AS Mgr_1,
SUM(CASE WHEN sID = '1X54322' AND col_nm = 'one_yr_sharpe_ratio' THEN value END) AS Mgr_2
FROM #mgr_calc_columns
UNION ALL
SELECT
'one_yr_up_capture' AS Mearurement,
SUM(CASE WHEN sID = '1X54321' AND col_nm = 'one_yr_up_capture' THEN value END) AS Mgr_1,
SUM(CASE WHEN sID = '1X54322' AND col_nm = 'one_yr_up_capture' THEN value END) AS Mgr_2
FROM #mgr_calc_columns
UNION ALL
SELECT
'one_yr_down_capture' AS Mearurement,
SUM(CASE WHEN sID = '1X54321' AND col_nm = 'one_yr_down_capture' THEN value END) AS Mgr_1,
SUM(CASE WHEN sID = '1X54322' AND col_nm = 'one_yr_down_capture' THEN value END) AS Mgr_2
FROM #mgr_calc_columns
UNION ALL
SELECT
'one_yr_downside_dev' AS Mearurement,
SUM(CASE WHEN sID = '1X54321' AND col_nm = 'one_yr_downside_dev' THEN value END) AS Mgr_1,
SUM(CASE WHEN sID = '1X54322' AND col_nm = 'one_yr_downside_dev' THEN value END) AS Mgr_2
FROM #mgr_calc_columns
UNION ALL
SELECT
'one_yr_ann_tracking_error' AS Mearurement,
SUM(CASE WHEN sID = '1X54321' AND col_nm = 'one_yr_ann_tracking_error' THEN value END) AS Mgr_1,
SUM(CASE WHEN sID = '1X54322' AND col_nm = 'one_yr_ann_tracking_error' THEN value END) AS Mgr_2
FROM #mgr_calc_columns
UNION ALL
SELECT
'one_yr_info_ratio' AS Mearurement,
SUM(CASE WHEN sID = '1X54321' AND col_nm = 'one_yr_info_ratio' THEN value END) AS Mgr_1,
SUM(CASE WHEN sID = '1X54322' AND col_nm = 'one_yr_info_ratio' THEN value END) AS Mgr_2
FROM #mgr_calc_columns
UNION ALL
SELECT
'one_yr_batt_avg' AS Mearurement,
SUM(CASE WHEN sID = '1X54321' AND col_nm = 'one_yr_batt_avg' THEN value END) AS Mgr_1,
SUM(CASE WHEN sID = '1X54322' AND col_nm = 'one_yr_batt_avg' THEN value END) AS Mgr_2
FROM #mgr_calc_columns
UNION ALL
SELECT
'threey_gross' AS Mearurement,
SUM(CASE WHEN sID = '1X54321' AND col_nm = 'threey_gross' THEN value END) AS Mgr_1,
SUM(CASE WHEN sID = '1X54322' AND col_nm = 'threey_gross' THEN value END) AS Mgr_2
FROM #mgr_calc_columns
UNION ALL
SELECT
'three_yr_ann_std_dev' AS Mearurement,
SUM(CASE WHEN sID = '1X54321' AND col_nm = 'three_yr_ann_std_dev' THEN value END) AS Mgr_1,
SUM(CASE WHEN sID = '1X54322' AND col_nm = 'three_yr_ann_std_dev' THEN value END) AS Mgr_2
FROM #mgr_calc_columns
UNION ALL
SELECT
'three_yr_sharpe_ratio' AS Mearurement,
SUM(CASE WHEN sID = '1X54321' AND col_nm = 'three_yr_sharpe_ratio' THEN value END) AS Mgr_1,
SUM(CASE WHEN sID = '1X54322' AND col_nm = 'three_yr_sharpe_ratio' THEN value END) AS Mgr_2
FROM #mgr_calc_columns
UNION ALL
SELECT
'three_yr_up_capture' AS Mearurement,
SUM(CASE WHEN sID = '1X54321' AND col_nm = 'three_yr_up_capture' THEN value END) AS Mgr_1,
SUM(CASE WHEN sID = '1X54322' AND col_nm = 'three_yr_up_capture' THEN value END) AS Mgr_2
FROM #mgr_calc_columns
UNION ALL
SELECT
'three_yr_down_capture' AS Mearurement,
SUM(CASE WHEN sID = '1X54321' AND col_nm = 'three_yr_down_capture' THEN value END) AS Mgr_1,
SUM(CASE WHEN sID = '1X54322' AND col_nm = 'three_yr_down_capture' THEN value END) AS Mgr_2
FROM #mgr_calc_columns
UNION ALL
SELECT
'three_yr_downside_dev' AS Mearurement,
SUM(CASE WHEN sID = '1X54321' AND col_nm = 'three_yr_downside_dev' THEN value END) AS Mgr_1,
SUM(CASE WHEN sID = '1X54322' AND col_nm = 'three_yr_downside_dev' THEN value END) AS Mgr_2
FROM #mgr_calc_columns
UNION ALL
SELECT
'three_yr_ann_tracking_error' AS Mearurement,
SUM(CASE WHEN sID = '1X54321' AND col_nm = 'three_yr_ann_tracking_error' THEN value END) AS Mgr_1,
SUM(CASE WHEN sID = '1X54322' AND col_nm = 'three_yr_ann_tracking_error' THEN value END) AS Mgr_2
FROM #mgr_calc_columns
UNION ALL
SELECT
'three_yr_info_ratio' AS Mearurement,
SUM(CASE WHEN sID = '1X54321' AND col_nm = 'three_yr_info_ratio' THEN value END) AS Mgr_1,
SUM(CASE WHEN sID = '1X54322' AND col_nm = 'three_yr_info_ratio' THEN value END) AS Mgr_2
FROM #mgr_calc_columns
UNION ALL
SELECT
'three_yr_batt_avg' AS Mearurement,
SUM(CASE WHEN sID = '1X54321' AND col_nm = 'thrree_yr_batt_avg' THEN value END) AS Mgr_1,
SUM(CASE WHEN sID = '1X54322' AND col_nm = 'three_yr_batt_avg' THEN value END) AS Mgr_2
FROM #mgr_calc_columns
UNION ALL
SELECT
'fivey_gross' AS Mearurement,
SUM(CASE WHEN sID = '1X54321' AND col_nm = 'fivey_gross' THEN value END) AS Mgr_1,
SUM(CASE WHEN sID = '1X54322' AND col_nm = 'fivey_gross' THEN value END) AS Mgr_2
FROM #mgr_calc_columns
UNION ALL
SELECT
'five_yr_ann_std_dev' AS Mearurement,
SUM(CASE WHEN sID = '1X54321' AND col_nm = 'five_yr_ann_std_dev' THEN value END) AS Mgr_1,
SUM(CASE WHEN sID = '1X54322' AND col_nm = 'five_yr_ann_std_dev' THEN value END) AS Mgr_2
FROM #mgr_calc_columns
UNION ALL
SELECT
'five_yr_sharpe_ratio' AS Mearurement,
SUM(CASE WHEN sID = '1X54321' AND col_nm = 'five_yr_sharpe_ratio' THEN value END) AS Mgr_1,
SUM(CASE WHEN sID = '1X54322' AND col_nm = 'five_yr_sharpe_ratio' THEN value END) AS Mgr_2
FROM #mgr_calc_columns
UNION ALL
SELECT
'five_yr_up_capture' AS Mearurement,
SUM(CASE WHEN sID = '1X54321' AND col_nm = 'five_yr_up_capture' THEN value END) AS Mgr_1,
SUM(CASE WHEN sID = '1X54322' AND col_nm = 'five_yr_up_capture' THEN value END) AS Mgr_2
FROM #mgr_calc_columns
UNION ALL
SELECT
'five_yr_down_capture' AS Mearurement,
SUM(CASE WHEN sID = '1X54321' AND col_nm = 'five_yr_down_capture' THEN value END) AS Mgr_1,
SUM(CASE WHEN sID = '1X54322' AND col_nm = 'five_yr_down_capture' THEN value END) AS Mgr_2
FROM #mgr_calc_columns
UNION ALL
SELECT
'five_yr_downside_dev' AS Mearurement,
SUM(CASE WHEN sID = '1X54321' AND col_nm = 'five_yr_downside_dev' THEN value END) AS Mgr_1,
SUM(CASE WHEN sID = '1X54322' AND col_nm = 'five_yr_downside_dev' THEN value END) AS Mgr_2
FROM #mgr_calc_columns
UNION ALL
SELECT
'five_yr_ann_tracking_error' AS Mearurement,
SUM(CASE WHEN sID = '1X54321' AND col_nm = 'five_yr_ann_tracking_error' THEN value END) AS Mgr_1,
SUM(CASE WHEN sID = '1X54322' AND col_nm = 'five_yr_ann_tracking_error' THEN value END) AS Mgr_2
FROM #mgr_calc_columns
UNION ALL
SELECT
'five_yr_info_ratio' AS Mearurement,
SUM(CASE WHEN sID = '1X54321' AND col_nm = 'three_yr_info_ratio' THEN value END) AS Mgr_1,
SUM(CASE WHEN sID = '1X54322' AND col_nm = 'three_yr_info_ratio' THEN value END) AS Mgr_2
FROM #mgr_calc_columns
UNION ALL
SELECT
'five_yr_batt_avg' AS Mearurement,
SUM(CASE WHEN sID = '1X54321' AND col_nm = 'thrree_yr_batt_avg' THEN value END) AS Mgr_1,
SUM(CASE WHEN sID = '1X54322' AND col_nm = 'three_yr_batt_avg' THEN value END) AS Mgr_2
FROM #mgr_calc_columns
Greg
_________________________________________________________________________________________________
The glass is at one half capacity: nothing more, nothing less.
October 8, 2008 at 8:25 am
Greg,
Thanks a lot for your help & effort taken for providing me the solution. I really appreciate your effort and help.
But i think you have hardcoded the managerid's. But it may vary each and every run.
sometime manager count may 2 or 3 or 5. We dont know the exact count.
if the count is 5, i.e we have 5 manager id. so we have to split thee result into 5.
karthik
October 8, 2008 at 8:36 am
Karthik
This is just my opinion, but it seems like the measurements are more stable than the managers. Wouldn't it be better to have the measurements as columns and managers as rows in your report? Then you would not have to pivot anything, and the changing of managers from month to month would not be a problem? I know that when some bosses get an idea for a report in their head, there is no shaking it, but they don't always know what they are talking about. But, then again, neither do I.
Greg
_________________________________________________________________________________________________
The glass is at one half capacity: nothing more, nothing less.
October 8, 2008 at 8:48 am
Greg,
You are absolutely correct. I asked to change the report format so many times. But he is expecting the same report format.
karthik
October 8, 2008 at 9:06 am
Greg,
is there any other work around to do the same ?
karthik
October 8, 2008 at 9:14 am
Have you tried the UNPIVOT solution?
October 8, 2008 at 9:20 am
No. I am using sql2000.
karthik
October 8, 2008 at 9:26 am
Sorry, I didn't notice that. :blush:
October 8, 2008 at 11:27 am
Sorry Karthik, variable column names would be way over my head.
Greg
_________________________________________________________________________________________________
The glass is at one half capacity: nothing more, nothing less.
October 8, 2008 at 1:40 pm
Karthik, check this out, I think it will work for you if you modify it a bit.
http://www.sqlservercentral.com/articles/Advanced+Querying/pivottableformicrosoftsqlserver/2434/
Greg
_________________________________________________________________________________________________
The glass is at one half capacity: nothing more, nothing less.
Viewing 15 posts - 16 through 30 (of 33 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy