-1
Greetings to you, gentlemen! I come once again to seek the guidance of the masters of DB! As the last time I have a query that returns a very specific result and that works,a but is slow and as the bank grows, slower becomes. Follow the model below.
SELECT DISTINCT V1_PAIS_NOME_PT AS PAIS,
(SELECT COUNT(*) FROM `TV1-VISITAS` WHERE V1_PAIS_NOME_PT = PAIS) AS TOTAIS,
(SELECT COUNT(DISTINCT V1_IP) FROM `TV1-VISITAS` WHERE V1_PAIS_NOME_PT = PAIS) AS UNICOS
FROM `TV1-VISITAS` WHERE V1_OS NOT LIKE '%bot%'
AND MONTH(V1_HORA) = MONTH(NOW())
ORDER BY TOTAIS DESC;
Thank you very much for your attention!