Review this request SQL server
select q.txt as Pregunta, a.txt as Respuesta,
(select count(1) from survey_question where owning_survey in (select id from survey where [object_id]=400005) and sequence=q.sequence and response = a.sequence) as Total
from survey_atpl a
inner join survey_qtpl q on (a.own_srvy_question =q.id)
where q.owning_survey = 400006
order by q.sequence, a.sequence
--Relación de observaciones
select a.first_name, a.last_name, s.nx_comment
from survey s
inner join ca_contact a on (a.contact_uuid = s. last_mod_by) where s.object_id=400005 and s.nx_comment not like ''
select q.sequence Numero_Pregunta, q.txt Pregunta, a.txt Respuesta,
DATEADD(hh,+1,dateadd(ss, a.last_mod_dt, '19700101')) as Fecha_hora,
c.last_name Apellido, c.first_name Nombre
from survey_answer a, ca_contact c, survey_question q
where a.last_mod_by = c.contact_uuid AND q.txt = 'Ubicación' AND q.id = a.own_srvy_question AND a.selected ='1' AND a.last_mod_dt > '1309305600'
Regards.