'Not Equal to'

A

ainese

I have a table with ESN and SERVICE types,
Each ESN can have up to 3 service types. I am trying to select where
SERVICE Type is only equal to basic, but i get duplicates with the
below query.

Can anyone help with what code can be used for this type of query
please?


SELECT DISTINCT (Count(F.ESN)) AS ["Basic Activations"]
FROM Data AS F INNER JOIN Data AS G ON (F.ESN= G.ESN AND F.SERVICE=
"Basic" AND G.SERVICE <>"Data Push" AND G.SUBSCR_TYPE = "Service
Activation")
WHERE G.ESN NOT IN
(SELECT ESN FROM Data WHERE SERVICE = 'Tracking' );


thanks in advance,
Aine
 
D

Douglas J Steele

The various checks for values in the table should not be in the ON clause:

SELECT DISTINCT (Count(F.ESN)) AS ["Basic Activations"]
FROM Data AS F INNER JOIN Data AS G ON (F.ESN= G.ESN)
WHERE G.ESN NOT IN (SELECT ESN FROM Data WHERE SERVICE = 'Tracking' )
AND F.SERVICE= "Basic"
AND G.SERVICE <>"Data Push"
AND G.SUBSCR_TYPE = "Service Activation"


"ainese" wrote in message

I have a table with ESN and SERVICE types,
Each ESN can have up to 3 service types. I am trying to select where
SERVICE Type is only equal to basic, but i get duplicates with the
below query.

Can anyone help with what code can be used for this type of query
please?


SELECT DISTINCT (Count(F.ESN)) AS ["Basic Activations"]
FROM Data AS F INNER JOIN Data AS G ON (F.ESN= G.ESN AND F.SERVICE=
"Basic" AND G.SERVICE <>"Data Push" AND G.SUBSCR_TYPE = "Service
Activation")
WHERE G.ESN NOT IN
(SELECT ESN FROM Data WHERE SERVICE = 'Tracking' );


thanks in advance,
Aine
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Query code for 'only equal to' 0
HELP PLEASE 3
Not Equal To 1
Is it possible to select only equal to 0
Select 'ONLY = TO' 1
HELP - selecting 0
Help Please 5
beginner sql query 0

Top