Skip to content

Commit 867bebc

Browse files
committed
not in vs null
1 parent c242732 commit 867bebc

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

Misc/NotIn-Null.sql

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ create table #vendas (
1616
,ip varchar(100)
1717
)
1818

19-
drop table if exists #blacklist;
20-
create table #blacklist (
19+
drop table if exists #regras;
20+
create table #regras (
2121
Hora int
2222
,ip varchar(100)
2323
,email varchar(100)
@@ -33,7 +33,7 @@ values
3333
,('20240102 15:39',150,'1.1.1.1')
3434
,('20240102 15:39',3000,'2.2.2.2')
3535

36-
insert into #blacklist(Hora,ip,email,dns,username)
36+
insert into #regras(Hora,ip,email,dns,username)
3737
values
3838
(15,'1.1.1.1',null,null,null)
3939
,(16,null,null,'*.test',null)
@@ -45,7 +45,7 @@ from
4545
#vendas v
4646
where
4747
v.ip not in (
48-
select b.ip from #blacklist b
48+
select b.ip from #regras b
4949
where b.Hora = datepart(hh,DataVenda)
5050
)
5151
group by
@@ -59,7 +59,7 @@ from
5959
#vendas v
6060
where
6161
v.ip not in (
62-
select b.ip from #blacklist b
62+
select b.ip from #regras b
6363
where b.Hora = datepart(hh,DataVenda)
6464
and b.ip is not null
6565
)
@@ -74,7 +74,7 @@ from
7474
#vendas v
7575
where
7676
v.ip not in (
77-
select isnull(b.ip,'') from #blacklist b
77+
select isnull(b.ip,'') from #regras b
7878
where b.Hora = datepart(hh,DataVenda)
7979
)
8080
group by
@@ -88,7 +88,7 @@ from
8888
#vendas v
8989
where
9090
not exists (
91-
select * from #blacklist b
91+
select * from #regras b
9292
where b.Hora = datepart(hh,DataVenda)
9393
and v.ip = b.ip
9494
)
@@ -106,7 +106,7 @@ from
106106
#vendas v
107107
where
108108
v.ip not in (
109-
select b.ip from #blacklist b
109+
select b.ip from #regras b
110110
where b.Hora = datepart(hh,DataVenda)
111111
)
112112
group by

0 commit comments

Comments
 (0)