You are here: Re: Problem counting records « MsSQL Server « IT news, forums, messages
Re: Problem counting records

Posted by Sir Hystrix on 11/30/07 13:30

Dan Guzman wrote:
>> What I would like to have returned is this: a list of messages where
>> Reply_to = 0 and the number of replies to this message.
>
> A subquery like the example below is one method.
>
> SELECT
> m.ID,
> m.Subject,
> (SELECT COUNT(*)
> FROM dbo.Messages
> WHERE Reply_to = m.ID
> ) AS Num_replies_to
> FROM dbo.Messages AS m
> WHERE Reply_to = 0
>

I knew it was simple. It had to be simple. I just didn't see it.
Many thanks to both Dan and Manfred.

Cheers.

 

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

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