freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
- From: "ZIGLIO, Frediano, VF-IT" <Frediano.Ziglio AT vodafone.com>
- To: <s.craig AT andronics.com>, "FreeTDS Development Group" <freetds AT lists.ibiblio.org>
- Subject: Re: [freetds] Query - Sum(data) by Date?
- Date: Thu, 10 Nov 2005 17:10:34 +0100
>
> How do i go about this, i have a single table 'Flow' which
> holds values
> for a particular object for a date, ie
>
> 'Object' 'Level' 'Date/Time'
>
> Object1 2.0 Nov 09 2005 10:02AM
> Object1 3.3 Nov 09 2005 11:32AM
> Object1 1.2 Nov 09 2005 13:12PM
> etc........
> Object1 3.4 Nov 10 2005 04:12AM
> Object1 0.1 Nov 10 2005 11:23PM
> etc...
>
> I want a query which will sum(level) for each date, so result
> will look
> like the following
>
> 'Object' 'Total Level for Date' 'Date'
>
> Object1 6.5 Nov 09 2005
> Object1 3.5 Nov 10 2005
>
> Any ideas, had a look on the web but you need to sign up to
> stuff to see
> solutions, not an option.
>
> Thanks,
>
> Shaun.
select Object, sum(Level) as [Total Level for Date], Date From
table_name group by Object, Date
Well... you group by date which is a (small)datetime, if (small)datetime
contains time you have to strip time part using come convert/cast like
select Object, sum(Level) as [Total Level for Date],
convert(smalldatetime, convert(varchar(20), Date, 112), 112) as Date
>From table_name group by Object, convert(smalldatetime,
convert(varchar(20), Date, 112), 112)
freddy77
-
[freetds] Query - Sum(data) by Date?,
Shaun Craig, 11/10/2005
- Re: [freetds] Query - Sum(data) by Date?, Jorge Cordero, 11/10/2005
- <Possible follow-up(s)>
- Re: [freetds] Query - Sum(data) by Date?, Зверев Виталий Борисович, 11/10/2005
- Re: [freetds] Query - Sum(data) by Date?, ZIGLIO, Frediano, VF-IT, 11/10/2005
-
Re: [freetds] Query - Sum(data) by Date?,
Thompson, Bill D (London), 11/10/2005
- Re: [freetds] Query - Sum(data) by Date?, Shaun Craig, 11/10/2005
- Re: [freetds] Query - Sum(data) by Date?, Owen, Robert, 11/10/2005
Archive powered by MHonArc 2.6.24.