Ciao a tutti, ho creato un database con questa struttura:

Giorno , ora, num1, num2, num3, num4, num5, num6.... num10


Inserendo una vettore di numeri devo selezionare le tuple che contengono almeno 2 dei numeri presenti nel vettore.
Io ho trovato una soluzione, ma richiede davvero troppo tempo, sicuramente sbaglio nella logica, potreste darmi una mano?

questa è la soluzione da me trovata, ma devo trovarne una molto piu' veloce:

codice:
select tab.*, count(*)as conta
 
from
(


select all *
 from esempio1.numeri where num1 in (3,5,11,16,24,29)
 
union all


select all *
from esempio1.numeri 
where num2 in (3,5,11,16,24,29)


union all


select all *
from esempio1.numeri 
where num3 in (3,5,11,16,24,29)


union all


select all *
from esempio1.numeri
 where num4 in (3,5,11,16,24,29)


union all


select all *
from esempio1.numeri
 where num5 in (3,5,11,16,24,29)


union all


select all *
from esempio1.numeri
 where num6 in (3,5,11,16,24,29)


union all


select all *
from esempio1.numeri
 where num7 in (3,5,11,16,24,29)


union all


select all *
from esempio1.numeri
 where num8 in (3,5,11,16,24,29)


union all


select all *
from esempio1.numeri
 where num9 in (3,5,11,16,24,29)


union all


select all *
from esempio1.numeri
 where num10 in (3,5,11,16,24,29)
)tab


group by giorno,estrazione


having count(*)>1


order by conta

il problema sostanziale è che in questa query il database viene riletto 10 volte