query oracle with filter.......
Hi, I've this table TAB_DV
COD_IMM..............DV_ID...............DP_ID
0102.................MS..................MSG
0102.................EN..................ENL
0103.................LI..................LIB
0103.................DO..................DOM
0103.................AT..................ATE
0104.................MS..................MSG
0105.................AT..................ATE
0105.................MS..................MSG
0106.................LI..................LIB
0107.................LI..................LIB
0107.................MS..................MSG
0107.................EN..................ENL
0108.................MS..................MSG
0108.................IT..................ITM
0109.................MS..................MSG
0109.................IT..................ITM
0109.................AT..................ATE
0109.................OS..................OSM
I'd like to find only the COD_IMM that have dp_id in ('MSG','ENL') or a.dp_id like ('%LI%'), without other dp_id.
for example:
0102 has 'MSG' and 'ENL'.........(YES)
0103 has 'LIB', 'DOM' and 'ATE'.........(NO)
0104 has 'MSG'..............(YES)
0105 has 'MSG' and 'ATE'...........(NO)
0106..............(YES)
0107..............(YES)
0108..............(NO)
0109..............(NO)
if I write:
select cod_imm, dv_id, dp_id
from TAB_DV
where (dp_id in ('MSG','ENL') or dp_id like ('%LI%'))
group by cod_imm, dv_id, dp_id
I get all COD_IMM.
How Can I write my query to get just the COD_IMM con 'MSG','ENL' or dp_id like ('%LI%'), without other dp_id?
Thanks in advance!