I’m making a be part of between 2 tables, the place they convey me number_phone which have a relationship and I carry the instances that these are repeated, nonetheless, I’m making an attempt to make a situation to the rely, in order that it solely lists these which can be repeated greater than 4 instances, I attempted with having account and it brings me the counter all in null. It’s value mentioning that I didn’t occupy group by for the rely as a result of it introduced me unsuitable values.
SELECT
REPLACE(REPLACE(t.id_contrato,'0999',''),'0998','')as contrato ,
t.num_telefono,
conc.valor_actual,
(
SELECT COUNT('x')
FROM TBL_TELEFONO ct
WHERE ct.num_telefono = t.num_telefono
AND ct.origen_tel='TELEFONO CONTRATO'
) as counter
FROM TBL_TELEFONO t
INNER JOIN CAM_TBL_ALERTA_CONCENTRADO conc ON t.num_telefono = conc.valor_actual
WHERE id_contrato IS NOT NULL
AND id_contrato NOT IN ('N/A')
ORDER BY 4 DESC
How can I checklist solely these which can be repeated greater than 4 instances?