oradbguru (6/25/2013)
Hello, I have the following query and I need the results in 1 row going across. Here is the query:
SELECT top(5)
ap.apptDte,
ap.begTime,
lc.locName,
ev.event,
pm.fname + ' ' + pm.lname
FROM
appts ap
join loc_mstr lc on lc.locID = ap.locID
join events ev on ev.eventID = ap.eventID
join prov_mstr pm on pm.provID = ap.rend_provID
WHERE
personID = '5D06AAE9-1B8D-461B-BAAB-633C1ED7ED43'
AND appt_date > GETDATE()
The results would have 25 columns on 1 row. Is this possible?
Thank you.
Yes it is possible. Please read the links in my signature about cross tabs. If you still need help then read the first link in my signature for best practices when posting questions.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/