Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an opposite of the "IN" function?

Tags:

sql

oracle

I have this query:

Select
Sysdate,Sum(Count(P.Init_Dtime))
From Player p,player_source ps
Where
Ps.Group_Id In (44,9,42,15,23,73,45,33,69,63,7,49,96,81,28,57,98,74,92,38) 
And P.Player_Id=Ps.Player_Id 
and
Trunc(p.Init_Dtime) > Trunc(Sysdate) - 7 
And
Trunc(P.Create_Dtime) >= To_Date('2012-mar-01','yyyy-mon-dd')
And Trunc(P.Create_Dtime) < To_Date('2015-sep-9','yyyy-mon-dd')
Group By Trunc(P.Init_Dtime)
Order By Trunc(P.Init_Dtime) Asc

I am using the "IN" function to include only Group_IDs that have certain numbers. The Group_ID column can have a value from 1-100. How do I change this query so the result includes all Group_Id numbers that are not (44,9,42,15,23,73,45,33,69,63,7,49,96,81,28,57,98,74,92,38)?

like image 254
Americo Avatar asked Dec 08 '22 21:12

Americo


1 Answers

You can use NOT to negate the expression.

So you could say :

Where
Ps.Group_Id NOT IN (44,9 ...)
like image 93
Peter Davidsen Avatar answered Dec 25 '22 21:12

Peter Davidsen