Skip to content

Instantly share code, notes, and snippets.

@juque
Created May 17, 2011 04:14
Show Gist options
  • Select an option

  • Save juque/975941 to your computer and use it in GitHub Desktop.

Select an option

Save juque/975941 to your computer and use it in GitHub Desktop.
SELECT count( * ) -1 as count,
a.rut_int,
a.rut2_int,
a.apa_int,
a.nom_int,
a.ama_int,
a.com_int,
a.ciu_int,
a.fon_int,
a.dir_int,
a.mail1_int,
a.mail2_int
FROM integrantes a
LEFT OUTER JOIN turnos_sol b ON b.rut_tursol=a.rut2_int
where a.rut2_int LIKE '%%' AND DATE_FORMAT(b.fec_tursol,'%Y-%m-%d') >= '2011-04-15'
AND DATE_FORMAT(b.fec_tursol,'%Y-%m-%d') <= '2011-05-15'
and a.estado_int=1
GROUP BY a.rut2_int,a.rut2_int,a.apa_int,a.nom_int,a.ama_int,a.com_int,a.ciu_int,a.fon_int,a.dir_int,a.mail1_int,a.mail2_int
ORDER BY count(*) asc limit 10;
select a.rut2_int,a.estado_int from integrantes a left outer join turnos_sol b on b.rut_tursol=a.rut2_int where DATE_FORMAT(b.fec_tursol,'%Y-%m-%d') >= '2011-04-15' AND DATE_FORMAT(b.fec_tursol,'%Y-%m-%d') <= '2011-05-15' and a.estado_int=1 group by a.rut2_int;
select distinct(rut_tursol) from turnos_sol b where DATE_FORMAT(b.fec_tursol,'%Y-%m-%d') >= '2011-04-15' and DATE_FORMAT(b.fec_tursol,'%Y-%m-%d') <= '2011-05-15';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment