Ver Mensaje Individual
  #5 (permalink)  
Antiguo 26/05/2011, 08:59
Avatar de gnzsoloyo
gnzsoloyo
Moderador criollo
 
Fecha de Ingreso: noviembre-2007
Ubicación: Actualmente en Buenos Aires (el enemigo ancestral)
Mensajes: 23.324
Antigüedad: 16 años, 5 meses
Puntos: 2658
Respuesta: problema con sentencia sql

Para que comprendas mejor, lo que Heimish2000 te quiere decir con ponerlo más estructurado es que postees el código SQL de esta forma, que permite ver bien cómo está armado:
Código SQL:
Ver original
  1. SELECT
  2.     Tabla.[CABLE REMARC] AS [Numero remarcado],
  3.     Tabla.[CABLE ANTER] AS [Numero anterior],
  4.     Tabla.[CAP CABLE] AS Capacidad,
  5.     COUNT(Tabla.ESTADO_HILO) AS Ocupados,
  6.     Tabla.[CAP CABLE]-COUNT(Tabla.ESTADO_HILO) AS Libres,
  7.     Tabla.CIUDAD AS Ciudad,
  8.     Tabla.SITIO_ETB AS [Sitio ETB A],
  9.     Tabla.SITIO_ETB2 AS [Sitio ETB B],
  10.     Tabla.TRONCAL AS Troncal,
  11.     Tabla.ESTADO_HILO AS Estado,
  12.     (COUNT(Tabla.ESTADO_HILO)*100)/Tabla.[CAP CABLE] AS [% - Porcentaje de ocupación]
  13. FROM
  14.     [BASE ODF CABLES ACCESO] AS Tabla
  15. WHERE
  16.     (((Tabla.[CABLE REMARC]) LIKE '7[0]###'
  17.     OR
  18.     (Tabla.[CABLE REMARC]) LIKE '7[1]###'
  19.     OR
  20.     (Tabla.[CABLE REMARC]) LIKE '8[0]###'))
  21. GROUP BY
  22.     Tabla.[CABLE REMARC],
  23.     Tabla.[CABLE ANTER],
  24.     Tabla.[CAP CABLE],
  25.     Tabla.CIUDAD,
  26.     Tabla.SITIO_ETB,
  27.     Tabla.SITIO_ETB2,
  28.     Tabla.TRONCAL,
  29.     Tabla.ESTADO_HILO
  30. HAVING
  31.     (((Tabla.CIUDAD)=[Formularios]![Ini_Cables BOGOTA SitioETB Acceso/Transp]![txt_Ciudad])
  32.     AND
  33.     ((Tabla.SITIO_ETB)=[Formularios]![Ini_Cables BOGOTA SitioETB Acceso/Transp]![cmb_SitioA])
  34.     AND
  35.     ((Tabla.SITIO_ETB2)=[Formularios]![Ini_Cables BOGOTA SitioETB Acceso/Transp]![cmb_SitioB])
  36.     AND
  37.     ((Tabla.ESTADO_HILO)="Ocupado"))
  38.     OR
  39.     (((Tabla.CIUDAD)=[Formularios]![Ini_Cables BOGOTA SitioETB Acceso/Transp]![txt_Ciudad])
  40.     AND
  41.     ((Tabla.SITIO_ETB)=[Formularios]![Ini_Cables BOGOTA SitioETB Acceso/Transp]![cmb_SitioB])
  42.     AND
  43.     ((Tabla.SITIO_ETB2)=[Formularios]![Ini_Cables BOGOTA SitioETB Acceso/Transp]![cmb_SitioA])
  44.     AND
  45.     ((Tabla.ESTADO_HILO)="Ocupado"))
  46. ORDER BY
  47.     (COUNT(Tabla.ESTADO_HILO)*100)/Tabla.[CAP CABLE];
De esta forma si se puede ver que es lo que se supone que hace, o al menos intentar entenderlo.
También sería bueno ver la estructura de tablas y eventualmente cómo salen las consultas reales (alguna imagen de tablas).
__________________
¿A quién le enseñan sus aciertos?, si yo aprendo de mis errores constantemente...
"El problema es la interfase silla-teclado." (Gillermo Luque)