Need some help coming up with a Pivot Table for the following scenario on SQL Server 2008. I don't normally do much more than basic SQL queries and this one has me a bit stumped.
View #1 - v_R_System (Need Name0 column from here) View #2 - v_GS_ADD_REMOVE_PROGRAMS (need DisplayName0 from here)
The non-pivot query looks like this:
SELECT DISTINCT sys.Name0 AS [SYSTEM NAME], arp_x86.DisplayName0 AS [ADD/REMOVE PROGRAMS]
FROM v_R_System AS sys LEFT OUTER JOIN
v_GS_ADD_REMOVE_PROGRAMS AS arp_x86 ON sys.ResourceID = arp_x86.ResourceID
WHERE (sys.Name0 LIKE 'SRV%')
GROUP BY arp_x86.DisplayName0, sys.Name0
The results from the query above simply displays two columns, one for System Name and the other for Add/Remove Programs data.
System Name Add/Remove Programs
------------------------------------
SRV01 APP01
SRV01 APP02
SRV01 APP03
SRV02 APP01
SRV02 APP03
The problem is that we get multiple rows for each server so what we want instead is to have 1 row for each server but have the list of software displayed across the top and then put an "*" in the software column if it is installed on a particular server.
System Name APP01 APP02 APP03
------------------------------------------
SRV01 * * *
SRV02 * *
Any assistance is greatly appreciated!
Thanks.