Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
Hi there...I have data like thisCode Field1 Field2-------------------------------------00001 K-198 00001 K-2000How to create result like this with single query not store procedureCode Field1 Field2-----------------------------------------00001 K-198 K-2000Ok Thank's
Sorry, my data should like thisCode Field1 Field2------------------0001 K-198 (NULL)0001 (NULL) K-2000and the result isCode Field1 Field2------------------0001 K-198 K-2000I mean result is not single field but three field
timmy
Master Smack Fu Yak Hacker
1242 Posts
Posted - 2004-08-20 : 00:30:46
Select Code, Max(Field1), Max(Field2)From tableGroup by Code
Kristen
Test
22859 Posts
Posted - 2004-08-20 : 03:01:49
That's gonna give ANSI Warnings about the NULLs, which may be a PITA if processed through ADO ...Might need to do some ghastly hack like
Select Code, Max(COALESCE(Field1, '')), Max(COALESCE(Field2, ''))From tableGroup by Code