Last active
December 30, 2015 05:59
-
-
Save carlossaraiva/7786448 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--Funções COUNT (CONTAR), SUM (SOMA), AVG (MEDIA), MIN (MINIMO), MAX (MAXIMO) | |
select COUNT(*), SUM(af_valor_af), AVG(af_valor_af), MIN(af_valor_af), MAX(Af_valor_af) | |
from af | |
--Agregação | |
select itb_qtde_parcelas, prd_codigo, SUM(Af_valor_af), COUNT(*) | |
from af | |
group by itb_qtde_parcelas, prd_codigo | |
select clt_cpf, COUNT(*) | |
from cliente_televenda | |
group by clt_cpf | |
having COUNT(*) > 1 | |
--Ranking | |
select af_data_cadastramento, af_valor_af, dense_rank() over(order by af_valor_af desc) | |
from af | |
select af_data_cadastramento, af_valor_af, prd_codigo, dense_rank() over(partition by prd_codigo order by af_valor_af desc) | |
from af | |
select clt_cpf, ROW_NUMBER() over(partition by clt_cpf order by clt_data_inclusao) as q | |
into #teste | |
from cliente_televenda | |
select | |
from #teste | |
where q > 1 | |
--Tabelas temp(excluidas automaticamente após termino da sessão). | |
select af_codigo, af_valor_af as valor, 10 q | |
into #teste | |
from af |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment