SQL excluding something from a list

Soldato
Joined
30 Sep 2005
Posts
16,678
I have a SQL query which returns all installed software across our network. Like this:

Adobe Lightroom
AMD Driver v2.2.1
Microsoft Office 2020
Nvidia CC

It's 3,330 lines and I want to start building up a list of things to exclude (like drivers, and stuff we don't want).

Rather than having a query like this

SELECT * FROM TABLE WHERE 'Title' NOT LIKE 'AMD Driver%' AND 'Title' NOT LIKE 'Nvidia%' AND.......AND......AND

Can I make the query a bit more elegant and reference perhaps a second table with everything we don't want?

Thanks!!
 
Right, got it working great thanks :D

Next little problem to solve...... the table looks like the top part of this image, but I'd like it to look like the bottom part

iCIxclS.jpg
 
That's effectively a pivot table you're asking for.
There are ways to create them but not with a single SQL statement. So it depends what platform you're on as to what you can use.
 
It can be done in SQL but it's an ugly query:

Code:
/* CREATE THE TABLE */
CREATE TABLE [dbo].[Application](
    [DisplayName0] [varchar](100) NULL,
    [Version0] [varchar](20) NULL,
    [Publisher0] [varchar](100) NULL,
    [Name0] [varchar](100) NULL
)

/* INSERT THE VALUES */
INSERT INTO Application(DisplayName0,Version0,Publisher0,Name0)
VALUES('ACTEnterprise 2.15.0.19','2.15.0.19','Access Control Technology','Computer1'),
('ACTEnterprise 2.15.0.19','2.15.0.19','Access Control Technology','Computer2'),
('ACTEnterprise 2.15.0.19','2.15.0.19','Access Control Technology','Computer3'),
('ACTEnterprise 2.15.0.19','2.15.0.19','Access Control Technology','Computer4'),
('CutePDF Writer 3.2','3.2','Acro Software Inc.','Computer1'),
('CutePDF Writer 3.2','3.2','Acro Software Inc.','Computer2'),
('CutePDF Writer 3.2','3.2','Acro Software Inc.','Computer3'),
('CutePDF Writer 3.2','3.2','Acro Software Inc.','Computer4')

/* SELECT THE DATA */
SELECT DisplayName0,Version0,Publisher0, STUFF(
(SELECT ',' + a2.Name0
FROM [Application] a2
WHERE a1.DisplayName0 = a2.DisplayName0
FOR XML PATH('')),1,1,'') AS Name0
FROM [Application] a1
GROUP BY DisplayName0,Version0,Publisher0
 
don't worry, I've added you to my list of oracles :D I'll no doubt need some more help soon :cry:

Your welcome buddy!

I taught myself power query/pivot as we dont have a source to ask for help so I am in between back end query and nowadays design reports too. I am hoping we get proper BI implementation sometime so I can use it for visuals like you shown above.
 
You could create a table with a list of what are apps and what are drivers. Then join on that with your first query.

I would want to cut excel out of the loop on this.
Especially if it going to be repeated regularly or at least annually.

But if you got want you wanted I guess job done.
 
Back
Top Bottom