Skip to content

Instantly share code, notes, and snippets.

@enlacee
Created October 7, 2013 21:12
Show Gist options
  • Save enlacee/6875051 to your computer and use it in GitHub Desktop.
Save enlacee/6875051 to your computer and use it in GitHub Desktop.
sub consulta mysql
SELECT
maa.idmarca,
maa.nombremarca,
(SELECT COUNT(*) FROM npc_detallebusqueda db
INNER JOIN npc_versionAutoEnte vae ON db.idauto = vae.idauto
INNER JOIN npc_version ve ON vae.idversion = ve.idversion
INNER JOIN npc_marca AS ma ON db.IdMarcaDetalleBusqueda = ma.idmarca
INNER JOIN npc_tipoauto AS t ON t.idtipoauto = db.IdTipoAutoDetalleBusqueda
WHERE (t.idTipoVehiculo = 1)
AND (ve.flagActivo = 1)
AND (vae.flagActivo = 1)
AND ma.idmarca = maa.idmarca
) AS conteo
FROM npc_marca maa
ORDER BY conteo DESC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment