Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Temp table

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-10-04 : 07:39:05
sai writes "Hi,

I have a query like this

select sum(total) as app from f where f.file_id = g.file_id
and f.wire = 1 and f.desc = 'app'

like above query i have to select sum(total) for different descriptions.I want to keep all these in temp table and use those fields in main table.How do i do that?Iam new to SQL
can anybody help me.

Thanks In Advance"

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-10-04 : 07:49:52
You have to JOIN the g-column too.


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2006-10-04 : 08:49:35
Like this??

Select f.Desc, Sum(Total) as app
into #temp
from f join g
on f.file_id = g.file_id
where f.wire = 1
group by f.Desc


Harsh Athalye
India.
"Nothing is Impossible"
Go to Top of Page
   

- Advertisement -