Ai mano, eu fiz a união das query de uma maneira diferente aqui que ficou como eu queria, só tem um porém, é quando inicia os dados do segundo select a classificação começa do 1º novamente, e o certo sería continuar, to tentando arrumar uma forma aqui…
o select ficou o seguinte.:
[code]select
ROW_NUMBER() over(order by min(ede.data),sum(ede.valortot) desc)
as ‘CLASSIFICAÇÃO’,
eee.nome as ‘NOME’,
convert(char(10),min(ede.data),103) as ‘DATA’,
+'R$ ’ +convert(varchar(10),sum(ede.valortot))
as ‘TOTAL A PAGAR’,
case
when matcpl.codcur = 1 then 'DIREITO’
when matcpl.codcur = 3 then 'MEDICINA’
when matcpl.codcur = 5 then 'SISTEMAS DE INFORMAÇÃO’
when matcpl.codcur = 6 then 'NUTRIÇÃO’
when matcpl.codcur = 7 then ‘ADMINISTRAÇÃO’
when matcpl.codcur = 8 then ‘EDUCAÇÃO FÍSICA’
end as ‘CURSO’,
max(turma.turma) as ‘TURMA’,
isnull(eee.telaluno,’-’) as 'TELEFONE’
from eee,
matcpl,
fl,
turma,
ede
where
fl.valorbaixado = 0.0000
and fl.datapag is null
and fl.databaixa is null
and ede.valorpago = 0
and ede.valortot > 0.00
and ede.datapag is null
and matcpl.mataluno = eee.matricula
and matcpl.mataluno = ede.mataluno
and matcpl.perletivo = ede.perletivo
and matcpl.codcur = ede.codcur
and turma.matricula = eee.matricula
and ede.mataluno = eee.matricula
and ede.codlanc = fl.idlan
and fl.statuslan in (0)
group by eee.nome,
eee.telaluno,
matcpl.codcur
having sum(ede.valortot) > 3000
UNION ALL
select
ROW_NUMBER() over(order by sum(ede.valortot)desc)
as ‘CLASSIFICAÇÃO’,
eee.nome as ‘NOME’,
convert(char(10),min(ede.data),103) as ‘DATA’,
+'R$ ’ +convert(varchar(10),sum(ede.valortot))
as ‘TOTAL A PAGAR’,
case
when matcpl.codcur = 1 then 'DIREITO’
when matcpl.codcur = 3 then 'MEDICINA’
when matcpl.codcur = 5 then 'SISTEMAS DE INFORMAÇÃO’
when matcpl.codcur = 6 then 'NUTRIÇÃO’
when matcpl.codcur = 7 then ‘ADMINISTRAÇÃO’
when matcpl.codcur = 8 then ‘EDUCAÇÃO FÍSICA’
end as ‘CURSO’,
max(turma.turma) as ‘TURMA’,
isnull(eee.telaluno,’-’) as 'TELEFONE’
from eee,
matcpl,
fl,
turma,
ede
where
fl.valorbaixado = 0.0000
and fl.datapag is null
and fl.databaixa is null
and ede.valorpago = 0
and ede.valortot > 0.00
and ede.datapag is null
and matcpl.mataluno = eee.matricula
and matcpl.mataluno = ede.mataluno
and matcpl.perletivo = ede.perletivo
and matcpl.codcur = ede.codcur
and turma.matricula = eee.matricula
and ede.mataluno = eee.matricula
and ede.codlanc = fl.idlan
and fl.statuslan in (0)
group by eee.nome,
eee.telaluno,
matcpl.codcur
having sum(ede.valortot) <= 3000
[/code]