You are here: Re: Getting count with multiple fields « MsSQL Server « IT news, forums, messages
Re: Getting count with multiple fields

Posted by Simon Hayes on 09/06/05 18:03

Assuming that there is only one possible officer and dispatcher for
each LogID, then you could do this:

select
count(a.LogID) as LogCount,
max(a.LogDispatcherID),
max(b.OfficerFirstname + ' ' + b.OfficerLastname) as
OfficerName
from
dbo.[Log] a
join dbo.Officer b
on a.LogAssigned1 = b.OfficerID
Group By
a.LogID

However, that may not be what you want, depending on what your data
looks like, if there can be several officers or dispatchers for each
LogID etc. So if this isn't helpful, or gives you the wrong answer, I
suggest you post CREATE TABLE and INSERT statements to set up a simple
test case - that way others can copy and paste into QA to test it.

http://www.aspfaq.com/etiquette.asp?id=5006

Simon

 

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

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