Ver Mensaje Individual
  #6 (permalink)  
Antiguo 19/01/2015, 13:22
plasma_go
 
Fecha de Ingreso: mayo-2014
Ubicación: Mexico
Mensajes: 79
Antigüedad: 10 años, 8 meses
Puntos: 2
Respuesta: Consulta dato no esperado

Estructura de las tablas:

Tabla agenda:
Código MySQL:
Ver original
  1. CREATE TABLE `agenda` (
  2.   `idAgenda` int(11) NOT NULL AUTO_INCREMENT,
  3.   `Rpu` varchar(12) DEFAULT NULL,
  4.   `HoraI` datetime DEFAULT NULL,
  5.   `HoraF` datetime DEFAULT NULL,
  6.   `idCausa` int(11) NOT NULL,
  7.   `idcatMatrix` int(11) NOT NULL,
  8.   `IsAllDayEvent` smallint(6) DEFAULT NULL,
  9.   `Color` varchar(1) DEFAULT NULL,
  10.   `idcatVentanilla` int(11) NOT NULL,
  11.   `Rpe` varchar(5) DEFAULT NULL,
  12.   PRIMARY KEY (`idAgenda`),
  13.   KEY `fk_Agenda_Causa1` (`idCausa`),
  14.   KEY `fk_Agenda_catMatrix1` (`idcatMatrix`),
  15.   KEY `fk_Agenda_catVentanilla1` (`idcatVentanilla`),
  16.   KEY `fk_Agenda_catUsuario1` (`Rpe`)

Tabla catventanilla
Código MySQL:
Ver original
  1. CREATE TABLE `catventanilla` (
  2.   `idcatVentanilla` int(11) NOT NULL AUTO_INCREMENT,
  3.   `idcatAgencia` varchar(5) DEFAULT NULL,
  4.   `noVentanilla` int(11) DEFAULT NULL,
  5.   PRIMARY KEY (`idcatVentanilla`)

select * from agenda

'10', '444444444444', '2015-01-16 08:00:00', '2015-01-16 08:10:00', '6', '1', '0', '1', '2', NULL
'11', '255899666333', '2015-01-20 08:00:00', '2015-01-20 08:10:00', '2', '1', '0', '1', '3', NULL
'12', '233333333333', '2015-01-09 08:00:00', '2015-01-09 08:10:00', '1', '2', '0', '1', '7', NULL
'13', '111111111111', '2015-01-14 12:20:00', '2015-01-14 12:30:00', '1', '2', '0', '1', '6', NULL
'14', '461564604654', '2015-01-13 13:10:00', '2015-01-13 13:20:00', '1', '2', '0', '1', '7', NULL
'15', '555555555555', '2015-01-14 13:00:00', '2015-01-14 13:10:00', '2', '2', '0', '1', '6', NULL
'16', '116551601111', '2015-01-14 12:20:00', '2015-01-14 12:30:00', '1', '2', '0', '6', '5', '9a0kl'
'17', '546546213215', '2015-01-14 12:30:00', '2015-01-14 12:40:00', '8', '2', '0', '1', '6', NULL
'18', '444444444444', '2015-01-27 08:00:00', '2015-01-27 08:10:00', '2', '2', '0', '1', '5', NULL
'19', '333444444444', '2015-01-16 08:00:00', '2015-01-16 08:10:00', '2', '2', '0', '1', '5', NULL
'20', '666666666666', '2015-01-21 08:00:00', '2015-01-21 08:10:00', '6', '1', '0', '1', '4', NULL

Resultado esperado:
idcatventanilla,total
'6', '1'
'5', '1'
'7', '0'