Click to See Complete Forum and Search --> : help


zhj
November 20th, 2007, 02:44 PM
table T1:
region area field st count
------- -- -- -- --
region1 area1 field1 st1 5
region1 area1 field1 st2 3
region1 area1 field2 st1 9
region1 area1 field2 st2 4

table T2:
region1 area1 field1 5 3
region1 area1 field2 9 4

in sql 2000, like to drop out the 'st' column and last column to appear as rows(table T2 is desired result).

davide++
November 21st, 2007, 04:09 AM
Hi all.

Very succinct explanation about what you want.

Probably you need to create a view using a query like this


SELECT region area field count
FROM T1


I hope this will help you.

davide++
November 21st, 2007, 06:51 AM
Well,

reading again my answer, I've found it's much more inaccurate than your question :))

But I don't understand what is the condition that changes count column to a row.

ComITSolutions
February 28th, 2008, 10:28 AM
table T1:
region area field st count
------- -- -- -- --
region1 area1 field1 st1 5
region1 area1 field1 st2 3
region1 area1 field2 st1 9
region1 area1 field2 st2 4

table T2:
region1 area1 field1 5 3
region1 area1 field2 9 4

in sql 2000, like to drop out the 'st' column and last column to appear as rows(table T2 is desired result).


select region,Area,Field,Sum( Case When St='st1' Then 1 else 0 end) St1,
Sum( Case When St='st2' Then 1 else 0 end) St2 From T1
Group By region,Area,Field

Hope This is what u wanted.