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 2000 Forums
 SQL Server Development (2000)
 displaying rows

Author  Topic 

soorma
Yak Posting Veteran

52 Posts

Posted - 2007-01-24 : 17:26:54
I have a sql query

SELECT PropertyName, PropertyValue, UserID FROM ProfilePropertyDefinition
INNER JOIN UserProfile ON
ProfilePropertyDefinition.PropertyDefinitionID = UserProfile.PropertyDefinitionID

which displays the results like this

propertyName propertyValue userid
FirstName Jon 1
LastName Doe 1
CompanyName yahoo 1

FirstName Mark 2
lastName doe 2
CompanyName MSN 2

The results i want to show are like this

FirstName Lastname CompanyName USerid
jon Doe yahoo 1
mark doe msn 2

Does any 1 can help with this


SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-01-24 : 18:06:30
Yes I can, but it is going to be cluttered because you didn't prefix your columns with table names.
SELECT		MAX(CASE WHEN propertyName = 'FirstName' THEN propertyValue END) AS FirstName,
MAX(CASE WHEN propertyName = 'LastName' THEN propertyValue END) AS LastName,
MAX(CASE WHEN propertyName = 'CompanyName' THEN propertyValue END) AS CompanyName,
userid
FROM (
SELECT PropertyName,
PropertyValue,
UserID
FROM ProfilePropertyDefinition AS ppd
INNER JOIN UserProfile AS up ON up.PropertyDefinitionID = ppd.PropertyDefinitionID
) AS d
GROUP BY userid
ORDER BY userid
If you post the table definitions, the query will look cleaner.


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

soorma
Yak Posting Veteran

52 Posts

Posted - 2007-01-24 : 18:26:41
Thanks for ur help
Go to Top of Page
   

- Advertisement -