GROUP BY ORACLE

EJEMPLO GROUP BY
*******************
select origen, sum(subtotal), sum(descuento), sum(total) from autorizacion
group by origen;


select paciente, origen, sum(subtotal), sum(descuento), sum(total) from autorizacion
where tipo_paciente IN('C','N')
group by origen, paciente;

select origen, min(total) as minimo_total, max(total) as maximo_total from autorizacion
group by origen
having origen = 'CE';

select origen, sum(subtotal), sum(descuento), sum(total) from autorizacion
group by origen, consultorio
having origen='CE' OR origen='EM'
order by origen desc;

select c.nombre, sum(a.subtotal), sum(a.descuento), sum(a.total) from autorizacion a, consultorio c
where  (c.consultorio = a.consultorio) and a.fecha_registro >= to_date('01/03/2013','DD/MM/YYYY') and a.fecha_registro <= to_date('31/03/2013','DD/MM/YYYY') AND a.USUARIO='XXX'
group by c.nombre;


--by Ing. Jhonatan Abal Mejia

Comentarios

Entradas populares

Ejercicios Consola Visual Basic.NET

Numero Capicua Visual Basic

Procedimientos Almacenados ORACLE