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.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2005-09-14 : 06:54:48
|
| Mark writes "Hi, I have table that have dynamic field from other table.id Date Category FieldValue FieldName1 09/06/2005 Agency QW12 Bill3 09/06/2005 Agency 12 Time5 09/06/2005 Agency OK DynamicI can convert it into one row,by using query.SELECT Date,Category,Max(Bill) Bill,Max(Time)Time, Max(Dynamic) Dynamic from (Select Date, Category(CASE WHEN FieldName='Bill'then Max(FieldValue) END) Bill, (CASE WHEN FieldName='Time' then Max(FieldValue) END) Time, (CASE WHEN FieldName='Dynamic'then Max(FieldValue)END) Dynamicfrom Table1 group by Date,Category) A Group by Date,CategoryDate Category Bill Time Dynamic09/06/05 Agency QW12 12 OKHow to instead of data in FieldName use veriable?In this case I can pick any dynamic field and display" |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|
|