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.
| Author |
Topic |
|
RJ256
Starting Member
3 Posts |
Posted - 2009-03-11 : 07:48:02
|
Hi GuysI have been trying to create a simple query and my mind has got a bit stuck. Basically I am searching a table which contains all the applications installed on the network joined this table to computer tableWhat I want to do is search for application named %Nortel% installed on all computers and from that list I want to search if those computers have Citrix% installed with a Yes/No row.The first problem I have is that it is only returning computers with both Nortel and Citrix also need the computers with just Nortel as well. I tried a few things like creating a join from #NThe second issue is creating the Yes No if Citrix is installed with a Citrix % (don’t think it can be done with a case) have been trying to get a substring to work.Any help would be really appreciated select distinctc.nameinto #N from Inv_AeX_OS_Add_Remove_Programs ajoin computer c on c.guid = a._resourceguidwhere a.name like '%Nortel%'select distinctc.Name,case ISNULL(a.name,'') when 'Citrix%' then 'Yes' else 'No' end [Citrix Presentation Server Client Installed] from Inv_AeX_OS_Add_Remove_Programs ajoin computer c on c.guid = a._resourceguid WHERE c.name in (select * from #N) and a.name not like 'citrix%'order by c.namedrop table #N |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
|
darkdusky
Aged Yak Warrior
591 Posts |
Posted - 2009-03-11 : 08:08:32
|
| Select name, [Citrix Presentation Server Client Installed] from (select distinctc.name, case ISNULL(a.name,'') when 'Citrix%' then 'Yes' else 'No' end [Citrix Presentation Server Client Installed] from Inv_AeX_OS_Add_Remove_Programs ajoin computer c on c.guid = a._resourceguidwhere a.name like '%Nortel%')where [Citrix Presentation Server Client Installed] ='Yes' |
 |
|
|
RJ256
Starting Member
3 Posts |
Posted - 2009-03-11 : 13:25:06
|
| Thanks for the new code not sure it is quite right as it seems come up with a syntax error around the second 'where' will have another look at it tomorrowCheersRJ |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-03-11 : 13:30:54
|
quote: Originally posted by RJ256 Thanks for the new code not sure it is quite right as it seems come up with a syntax error around the second 'where' will have another look at it tomorrowCheersRJ
its because of missing aliasSelect name, [Citrix Presentation Server Client Installed] from (select distinctc.name, case ISNULL(a.name,'') when 'Citrix%' then 'Yes' else 'No' end AS [Citrix Presentation Server Client Installed] from Inv_AeX_OS_Add_Remove_Programs ajoin computer c on c.guid = a._resourceguidwhere a.name like '%Nortel%')twhere [Citrix Presentation Server Client Installed] ='Yes' |
 |
|
|
RJ256
Starting Member
3 Posts |
Posted - 2009-03-24 : 07:30:06
|
| Have problem with the code in that you can't use 'Citrix%' as it does not recognise the % as a wildcard instead wants an exact match like Citrix Presentation Server but I need to include all variants of citrix.c.name, case ISNULL(a.name,'') when 'Citrix%' then 'Yes' else 'No' end AS [Citrix Presentation Server Client Installed] |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-03-25 : 13:03:16
|
| make itc.name, case when ISNULL(a.name,'') like 'Citrix%' then 'Yes' else 'No' end AS [Citrix Presentation Server Client Installed] |
 |
|
|
|
|
|
|
|