Ver Mensaje Individual
  #4 (permalink)  
Antiguo 12/02/2009, 03:09
quimfv
Colaborador
 
Fecha de Ingreso: marzo-2008
Ubicación: Sabadell
Mensajes: 4.897
Antigüedad: 16 años, 2 meses
Puntos: 574
Respuesta: como ordenar con dos criterios

Código sql:
Ver original
  1. SELECT sbc.NOMBRES,
  2.              sbc.APELLIDOS,
  3.              sbc.ENTIDAD,
  4.              sbc.SECTOR,
  5.              sbc.NUMEROENELTARJETON,
  6.              sbc.NUMERODEVOTOS
  7. FROM (SELECT i.NOMBRES,
  8.                      i.APELLIDOS,
  9.                      i.ENTIDAD,
  10.                      i.SECTOR,
  11.                      e.NUMEROENELTARJETON,
  12.                      COUNT(*) AS NUMERODEVOTOS
  13. FROM INSCRITOS i INNER JOIN ESCRUTINIO e
  14.         ON i.NUMEROENELTARJETON=e.NUMEROENELTARJETON
  15.         GROUP BY i.NOMBRES,
  16.                        i.APELLIDOS,
  17.                        i.ENTIDAD,
  18.                        i.SECTOR,
  19.                        e.NUMEROENELTARJETON) AS sbc
  20. ORDER BY sbc.Sector ASC,
  21.                 sbc.NUMERODEVOTOS DESC

flaviovich La subconsulta es para poder ordenar por el resultado del count(*). Poniendo el numero de la columna te lo ordena?

marthalucia Insisto esto creo que da lo que pides.

Quim