I see the problem (it is actually in the last SQL I wrote for you as well, it just didn't matter there). This is probably what you want:
SELECT b.id_respuesta , COUNT(b.id_respuesta) AS cnt, b.id_aspecto FROM huesped a, rompe_encuesta b WHERE b.id_huesped = a.id_huesped AND b.id_aspecto >= 1 AND b.id_aspecto <= 4 AND a.fecha BETWEEN '2012-12-01' AND '2012-12-12' GROUP BY b.id_respuesta, b.id_aspecto; The important change here is adding "b.id_aspecto" to the GROUP BY clause. I forgot to add that earlier, which is why you are having problems now. Also, you don't need to do the range matching for id_respuesta for each id_aspecto as long as your data set doesn't cross over (ie, none of the id_aspecto = 1 records have invalid values for id_respuesta). On Friday, December 14, 2012 11:51:30 PM UTC-5, Chrystopher Medina wrote: > > > > hi my friend u know ... look i have this in mysql > > +--------------+---------------------+ > | id_respuesta | respuesta | > +--------------+---------------------+ > | 1 | excelente | > | 2 | bueno | > | 3 | regular | > | 4 | malo | > | 5 | si | > | 6 | no | > | 7 | no respondio | > | 8 | recomendacion | > | 9 | anuncio revista | > | 10 | letrero carretera | > | 11 | google | > | 12 | directo al hotel | > | 13 | llamada al 800 | > | 14 | sitio web del hotel | > | 15 | sitio web de otros | > | 16 | agencia de viajes | > | 17 | otros | > +--------------+---------------------+ > > and i have this another table :: > > +------------+------------------------------------------- > +---------+ > | id_aspecto | aspecto > | id_area | > +------------+------------------------------------------- > +---------+ > | 1 | como supo de este hotel | > 1 | > | 2 | como fueron atendidas sus reservaciones | 2 | > | 3 | a travez de que medio hizo su reservacion | 2 | > | 4 | botones > | 3 | > | 5 | recepcionista > | 3 | > | 6 | telefonos > | 3 | > | 7 | seguridad > | 3 | > | 8 | limpieza > | 4 | > | 9 | mantenimiento > | 4 | > | 10 | atencion de la camarista > | 4 | > > > and when i want to try this its ok:: > > SELECT b.id_respuesta , COUNT(b.id_respuesta) AS cnt, b.id_aspecto > FROM huesped a, rompe_encuesta b > WHERE > b.id_huesped = a.id_huesped AND > ((b.id_aspecto = 1 AND b.id_respuesta >= 1 AND b.id_respuesta <= 17) > OR > (b.id_aspecto = 2 AND b.id_respuesta >= 1 AND b.id_respuesta <= 17)) > AND > a.fecha BETWEEN '2012-12-01' AND '2012-12-12' > GROUP BY b.id_respuesta; > this query displays this result: > > +--------------+-----+------------+ > | id_respuesta | cnt | id_aspecto | > +--------------+-----+------------+ > | 1 | 1 | 2 | > | 2 | 2 | 2 | > | 3 | 1 | 2 | > | 4 | 1 | 2 | > | 7 | 3 | 2 | > | 8 | 3 | 1 | > | 9 | 1 | 1 | > | 10 | 1 | 1 | > | 11 | 3 | 1 | > +--------------+-----+------------+ > > > but when i try the next part ::::: its wrong:: i think that its because > .... id_aspecto=1 has id_respuesta between 8 and 11,,, > and id_aspecto=2 has id_respuesta between 1 and 7... and id_aspecto = 3 > has id_respuesta between 12 and 17... > but id_aspecto =4 has too id_respuesta between 1 and 7.... > > SELECT b.id_respuesta , COUNT(b.id_respuesta) AS cnt, b.id_aspecto > FROM huesped a, rompe_encuesta b > WHERE > b.id_huesped = a.id_huesped AND > ((b.id_aspecto = 1 AND b.id_respuesta >= 1 AND b.id_respuesta <= 17) > OR > (b.id_aspecto = 2 AND b.id_respuesta >= 1 AND b.id_respuesta <= 17) > OR > (b.id_aspecto = 3 AND b.id_respuesta >= 1 AND b.id_respuesta <= 17) > OR > (b.id_aspecto = 4 AND b.id_respuesta >= 1 AND b.id_respuesta <= 17)) > AND > a.fecha BETWEEN '2012-12-01' AND '2012-12-12' > GROUP BY b.id_respuesta; > > this query dysplays this result : > > +--------------+-----+------------+ > | id_respuesta | cnt | id_aspecto | > +--------------+-----+------------+ > | 1 | 5 | 2 | > | 2 | 2 | 2 | > | 3 | 1 | 2 | > | 4 | 1 | 2 | > | 7 | 11 | 2 | > | 8 | 3 | 1 | > | 9 | 1 | 1 | > | 10 | 1 | 1 | > | 11 | 3 | 1 | > | 12 | 1 | 3 | > | 13 | 1 | 3 | > | 15 | 1 | 3 | > | 17 | 1 | 3 | > +--------------+-----+------------+ in this id_aspecto is not here.. and > has not id_respuesta... but when i do this look.:: > > > select b.id_respuesta, count(b.id_respuesta) as cnt > from huesped a, rompe_encuesta b > where b.id_huesped = a.id_huesped and > b.id_aspecto = 4 and > b.id_respuesta >= 1 and > b.id_respuesta <= 17 and > a.fecha between '2012-12-01' and '2012-12-12' > group by b.id_respuesta; > > and the result is this: > > +--------------+-----+ > | id_respuesta | cnt | > +--------------+-----+ > | 1 | 4 | > | 7 | 4 | > +--------------+-----+ > the id_aspecto=4 has 2 id_respuesa ......... example cnt is the number of > persons that answered that id_aspecto=4 said that the service is > id_respuesta=1(excelent)... > -- You received this message because you are subscribed to the Google Groups "Google Visualization API" group. To view this discussion on the web visit https://groups.google.com/d/msg/google-visualization-api/-/7yoOsJvbqnoJ. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-visualization-api?hl=en.
