You are here: Re: Problem with SUM « MsSQL Server « IT news, forums, messages
Re: Problem with SUM

Posted by Ray Greene on 10/13/05 04:36

On 12 Oct 2005 03:03:24 -0700, "David Portas"
<REMOVE_BEFORE_REPLYING_dportas@acm.org> wrote:

>Don't assume it is obvious what is wrong. It helps to say exactly what
>error message you got and also to post enough code to reproduce the
>problem - at least a CREATE TABLE statement.

OK, I'll do that in future.

>In this case you missed the GROUP BY:
>
>SELECT location, machinename, SUM(hours)
> FROM tbl
> WHERE date >= '20050101'
> AND date < '20060101'
> GROUP BY location, machinename ;

Well that was simple enough compared to what I was trying to do.

I had assumed that it would take a nested query, I guess I shouldn't jump to
conclusions when I don't know what I'm doing :-)

>It is usually easier to specify date ranges as >= and < unless you are
>sure that the DATETIMEs will never contain times other than midnight.

Good point, I'll do it that way.

Thanks for the help David, it's much appreciated.

-
Ray Greene.

 

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

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