2
I need some help from you guys, i have a query on my system, which has 4 cases
SELECT TOP 3 * FROM (
SELECT Title, SUM(Count) AS Count
FROM (
SELECT
CASE WHEN EstadoId = EstadoIdAutor AND EstadoId = Meddoc1 AND EstadoId = Meddoc2 AND EstadoId = Meddoc3 THEN
'Sem deslocamento'
ELSE
CASE WHEN EstadoId = EstadoIdAutor AND (EstadoId = Meddoc1 OR EstadoId = Meddoc2 OR EstadoId = Meddoc3) THEN
'Fora de domicílio do autor'
ELSE
CASE WHEN EstadoId <> EstadoIdAutor OR (EstadoId = EstadoIdAutor AND (EstadoId <> Meddoc1 AND EstadoId <> Meddoc2 AND EstadoId <> Meddoc3)) THEN
'Mais de um deslocamento'
ELSE 'Outros'
END
END
END AS Title,
COUNT(*) AS Count
FROM jud_Processos
WHERE Status = 1 AND Trancado = 1 {dados}
GROUP BY EstadoId, EstadoIdAutor, Meddoc1, Meddoc2, Meddoc3
) Sub
GROUP BY Title
) TB_AUX
I wanted to know if it is possible to divide this query that in the case would be in 4 parts
No commuting - Out of place of the author - More than one commuting - Other
It is possible?
To be more specific, each case
in a select
.
What is the database manager: Mysql? Oracle Database? SQL Server? other?
– José Diz
SQL Server Amigo
– Leonardo Macedo