usando o TQuery do Bde funciona; usando o TSQLDataSet do DBExpress
dá o seguinte erro:

SQL State : 42000,SQL Error Code: 170
Line 1: Incorrect syntax near ','.

não se arrumar este erro; o código está abaixo,
grato
Stainle

select substring(mat.tcodigo, 1, 3) as linha, mat.tiimes, mat.tiano, 
sum(mat.ttotal) as Matriz,
(select  sum(f03.ttotal) from esif03 f03
where (substring(mat.tcodigo, 1, 3) = substring(f03.tcodigo, 1, 3)) 
and (mat.tiimes = f03.tiimes) and (mat.tiano = f03.tiano)
and (f03.tiopera = 2) and (f03.tihisto = 'S')) as Brasilia,
(select  sum(f04.ttotal) from esif04 f04
where (substring(mat.tcodigo, 1, 3) = substring(f04.tcodigo, 1, 3)) 
and (mat.tiimes = f04.tiimes) and (mat.tiano = f04.tiano)
and (f04.tiopera = 2) and (f04.tihisto = 'S')) as Poa,
(select  sum(f05.ttotal) from esif05 f05
where (substring(mat.tcodigo, 1, 3) = substring(f05.tcodigo, 1, 3)) 
and (mat.tiimes = f05.tiimes) and (mat.tiano = f05.tiano)
and (f05.tiopera = 2) and (f05.tihisto = 'S')) as Belo,
(select  sum(f06.ttotal) from esif06 f06
where (substring(mat.tcodigo, 1, 3) = substring(f06.tcodigo, 1, 3)) 
and (mat.tiimes = f06.tiimes) and (mat.tiano = f06.tiano)
and (f06.tiopera = 2) and (f06.tihisto = 'S')) as Curitiba,
(select  sum(f07.ttotal) from esif07 f07
where (substring(mat.tcodigo, 1, 3) = substring(f07.tcodigo, 1, 3)) 
and (mat.tiimes = f07.tiimes) and (mat.tiano = f07.tiano) 
and (f07.tiopera = 2) and (f07.tihisto = 'S')) as SantaCata
    from esimat mat
where (mat.tiimes = :pmes) and (mat.tiano = :pano) and (mat.tiopera = 
2) and (mat.tihisto = 'S')
group by mat.tiimes, mat.tiano, substring(tcodigo, 1, 3)
order by linha





-- 
<<<<< FAVOR REMOVER ESTA PARTE AO RESPONDER ESTA MENSAGEM >>>>>

<*> Para ver as mensagens antigas, acesse:
    http://br.groups.yahoo.com/group/delphi-br/messages

<*> Para falar com o moderador, envie um e-mail para:
    [EMAIL PROTECTED]
 
Links do Yahoo! Grupos

<*> Para visitar o site do seu grupo na web, acesse:
    http://br.groups.yahoo.com/group/delphi-br/

<*> Para sair deste grupo, envie um e-mail para:
    [EMAIL PROTECTED]

<*> O uso que você faz do Yahoo! Grupos está sujeito aos:
    http://br.yahoo.com/info/utos.html

 

Responder a