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
 Development Tools
 ASP.NET
 sql Help

Author  Topic 

REEPER
Yak Posting Veteran

53 Posts

Posted - 2008-02-14 : 16:01:24
Is there a way to change this query:

SELECT UserDefinedData.UserDefinedFieldId, UserDefinedData.UserDefinedRowId, UserDefinedFields.FieldTitle, UserDefinedData.FieldValue
FROM UserDefinedData INNER JOIN
UserDefinedFields ON UserDefinedData.UserDefinedFieldId = UserDefinedFields.UserDefinedFieldId INNER JOIN
UserDefinedRows ON UserDefinedData.UserDefinedRowId = UserDefinedRows.UserDefinedRowId
WHERE (UserDefinedRows.ModuleId = 681) AND (UserDefinedData.UserDefinedFieldId > 62)
ORDER BY UserDefinedData.UserDefinedRowId, UserDefinedData.UserDefinedFieldId

That produces this example result:

63 1396 Title Test
64 1396 Summary <p>This is a test of the new job posting system...this is only a test</p>
65 1396 Functions <p>test</p>
66 1396 Education <p>test</p>
67 1396 Knowledge <p>test</p>
68 1396 Locations South Hill, VA
70 1396 Qualifications <p>test</p>
63 1397 Title Testing
64 1397 Summary <p>Test</p>
65 1397 Functions <p>test</p>
66 1397 Education <p>test</p>
67 1397 Knowledge <p>test</p>
68 1397 Locations test


Column1 = UserDefinedFieldID
Column2 = UserDefinedRowID
Column3 = FieldTitle
Column4 = FieldValue

I would like flatten out the above dataset and return just 2 rows.

So the columns would be:
Title | Summary | Functions | Education | Knowledge | Locations | Qualifications

I've heard use the PIVOT function but I have been unsuccessful creating the coorect syntax


MCP, MCSD

jobejufranz
Starting Member

33 Posts

Posted - 2008-02-27 : 05:22:38
Hi,

have you found the solution because if not maybe i can help you rewrite the query

cheers.
Go to Top of Page
   

- Advertisement -