@@ -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 )
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)
3737values
3838 (15 ,' 1.1.1.1' ,null ,null ,null )
3939 ,(16 ,null ,null ,' *.test' ,null )
4545 #vendas v
4646where
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 )
5151group by
5959 #vendas v
6060where
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 )
7474 #vendas v
7575where
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 )
8080group by
8888 #vendas v
8989where
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 )
106106 #vendas v
107107where
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 )
112112group by
0 commit comments