Quantcast
Channel: Update com select count
Viewing all articles
Browse latest Browse all 2

Update com select count

$
0
0

Boa tarde

Tenho um script que é formado assim:

drop table #Eee

 

create table #Eee(

ano int,

mes int, t1 int, t2 int, t3 int, t4 int )

 

insert into #Eee (ano,mes)

select year(dataHora) as ano,month(dataHora) as mes

from manifesto 

group by year(dataHora),month(dataHora)

 

select * from #Eee

até aqui td bem..trouxe o ano e o mês da tabela Manifesto

 

Porem em outro script, quero usar update, assim:

 

update #Eee set t1 = (

select count( * )  from manifesto,#Eee as ee  

where codigoManifestoTipo=1 

and year(dataHora) = ee.ano 

and month(dataHora) = ee.mes

)

where ano = manifesto.year(dataHora) 

and mes = manifesto.month(dataHora)


Esta me retornando este erro:

Cannot find either column "manifesto" or the user-defined function or aggregate "manifesto.year", or the name is ambiguous.

Obrigado pela ajuda de todos.


edson

Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images