Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 How to Group this?

Author  Topic 

djorre
Yak Posting Veteran

94 Posts

Posted - 2009-05-13 : 08:47:27
Hi friends,

Im learning how to cross tab.
Used something like this
Select
Recipe,
Case When DescriptAPI='ACTION_OVER_RANGE' THEN PValueAPI + ' ' + EU ELSE null END as ACTION_OVER_RANGE,
Case When DescriptAPI='ACTION_UNDER_RANGE' THEN PValueAPI + ' ' + EU ELSE null END as ACTION_UNDER_RANGE,

Then I get a table full off nulls, which has to be grouped, which is no problem because every column contains only 1 value per ID.

So I already have a query like this

Recipe - Sensor 1 - Sensor 2 - Sensor 3
1 NULL NULL 5
1 5 NULL NULL
1 NULL NULL NULL
2 NULL NULL NULL
2 1 NULL NULL
2 NULL 7 NULL
2 NULL NULL NULL
4 7 NULL NULL
4 NULL NULL 3

It most become in this form:

Recipe - Sensor1 - Sensor2 - Sensor3
1 5 NULL 5
2 1 7 NULL
4 7 NULL 3

How to do this? Please help.

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-05-13 : 08:57:42
Put

max( case ... end )
...
group by reciepe


E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

djorre
Yak Posting Veteran

94 Posts

Posted - 2009-05-13 : 09:00:11
Thank you SO much for that super fast respons!
I love this forum
Go to Top of Page
   

- Advertisement -