Re: Grouping Dates



msg (msg35803@xxxxxxxxx) writes:
> SELECT TOP 100 w.TimeDate AS [date], p.ProdCode, COUNT(w.BoxID) AS
> cases, AVG(w.PrintedWeight / w.PkgsPerBox) AS avgtrayweight
> FROM dbo.WIPSixtyDay w INNER JOIN
> dbo.Products p ON w.PLUNo = p.PLUNo
> WHERE (p.PrePack = 1) AND (w.PkgsPerBox > 0)
> GROUP BY w.TimeDate, p.ProdCode
> ORDER BY w.TimeDate
>
>
> This is what I need to do...... sum these by the date(w.timedate) my
> original I was converting it to a string, but then none of my date
> queries would work....

I'm sorry, but I will have to ask: what is the question?




--
Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
.



Relevant Pages

  • Re: [SQL query] Generate a report from events?
    ... sum of device #1 between midnight and 10:00: ... DECLARE @endtime datetime; ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ... Books Online for SQL Server 2005 at ...
    (comp.databases.ms-sqlserver)
  • Re: I upsized but these SQL statements are causing errors...
    ... I'm not too sure but according to books online they are usable here is what ... Returns the sum of all the values, or only the DISTINCT values, in the ... Returns one of two numeric or string values determined by a logical test. ... > what is the sql server equivalent sql of sum and iif? ...
    (microsoft.public.inetserver.asp.db)
  • Re: sum date time differentce
    ... I got can not sum date time format error message. ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ... Books Online for SQL Server 2005 at ...
    (microsoft.public.sqlserver.programming)
  • Re: Need help with SQL satement - newbie
    ... than one record for a given 'siteID' then it needs to total (sum) most ... Judging from the syntax, you are not using SQL Server (which is what ... Books Online for SQL Server 2005 at ...
    (comp.databases.ms-sqlserver)
  • Re: Tough Sql Query
    ... wanted SUMbut the desired output you posted earlier ... That sum is hopefully always 0, or else something is really broken! ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ... Books Online for SQL Server 2005 at ...
    (comp.databases.ms-sqlserver)