Pular para o conteúdo

Fóruns SQL e PL/SQL Como montar essa SQL? Como montar essa SQL?

#92460
facc
Participante

    Vamos ver se essas SQLs pode te ajudar.

    Mostra Vendas a Vista
    Select Loja,
    sum(VlrCurso) VV
    from Cybelar_CrescaBr
    where tipo = 1
    and to_char(DtVenda, 'MM/yyyy') = '01/2010'
    and (Faturado = 'S')
    and length(contrato) < 9
    group by loja
    ORDER BY LOJa;

    Mostra Vendas a Prazo
    Select Loja,
    sum(VlrCurso) Prazo
    from Cybelar_CrescaBr
    where tipo = 1
    and to_char(DtVenda, 'MM/yyyy') = '01/2010'
    and (Faturado = 'S')
    and length(contrato) >= 9
    group by loja
    ORDER BY LOJa

    Exibe Pedidos Parados Anteriores ao mês escolhido
    Select Loja,
    sum(VlrCurso) parado
    from Cybelar_CrescaBr
    where tipo = 1
    and DtVenda < last_day(to_date('01/01/2010'))
    and (Faturado = 'N' or Faturado is null)
    group by loja
    ORDER BY LOJA;

    Exibe Pedidos Parados do mês escolhido
    Select Loja,
    sum(VlrCurso) atual
    from Cybelar_CrescaBr
    where tipo = 1
    and to_char(DtVenda, 'MM/yyyy') = '01/2010'
    and (Faturado = 'N' or Faturado is null)
    group by loja
    ORDER BY LOJA;

    Agora preciso juntar esses 4 Selects em um e no final fazer a conferencia (conforme explicado nos tópicos anteriores)