You are here: Need help with Count function and temporary tables « MsSQL Server « IT news, forums, messages
Need help with Count function and temporary tables

Posted by Danielle on 11/21/05 22:39

I have data like this in a two column temporary table -

ID Age

23586 3
23586 3
23586 2
23586 2
23586 1
23586 1
23586 1
23586 1
23586 1

I need to create a temporary table that look like this:

ID Age1 Age2 Age3 Age4

23586 5 2 2 0

However, what I get is this:

23586 5 NULL NULL NULL
23586 NULL 2 NULL NULL
23586 NULL NULL 2 NULL

Here is the query that I am using...
select managed_object_id, (select count(Age) where Age = 1) As Age1,
(select count(Age) where Age = 2) as Age2,
(select count(Age) where Age = 3) as Age3,
(select count(Age) where Age = 4) as Age4
into #enhancementCount from #enhancements
group by managed_object_id, Age

Where's my mistake?

Thanks-
Danielle

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация