OCURRENCIA], COUNT(Fecha_Ocurrencia_Caso)[QUEJAS],(SELECT COUNT(*) FROM PQR) FROM PQR GROUP BY R_Afiliado_RID, Fecha_Ocurrencia_Caso HAVING COUNT(*)>1 ORDER BY QUEJAS DESC
SELECT Radicado, MAX(CONVERT (date, Fecha_Ocurrencia_Caso))[FECHA OCURRENCIA] FROM
PQR WHERE R_Afiliado_RID=74262374 GROUP BY Radicado, Fecha_Ocurrencia_Caso
SELECT A.R_Afiliado_RID, COUNT(*)[NPQR] FROM (
SELECT COUNT(*)AS CO, MAX(Fecha_Ocurrencia_Caso)FE, R_Afiliado_RID FROM PQR GROUP BY R_Afiliado_RID ) A INNER JOIN PQR P ON A.R_Afiliado_RID=P.R_Afiliado_RID GROUP BY A.R_Afiliado_RID ORDER BY NPQR DESC
(Select count(*) from PQR o inner join
(Select R_Afiliado_RID as Afil,MAX(Fecha_Ocurrencia_Caso) as FEch from PQR group by R_Afiliado_RID,Fecha_Ocurrencia_Caso )k on k.Afil=o.R_Afiliado_RID where o.R_Afiliado_RID=A.ID) as PQR
Select COUNT(*),Max(Fecha_Ocurrencia_Caso) from PQR where
R_Afiliado_RID='75331245' group by Fecha_Ocurrencia_Caso Edwin Lopez20:20 CASE WHEN LEN (M.Codigo_Municipio)=5 THEN Codigo_Municipio ELSE '23001' END AS Municipios,
Case when len(GM.Codigo_Municipio)=5 then GM.Codigo_Municipio