🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.interbase.sql
Article #537

Re: Extract use

#537
From: Zoren Lendry
Date: Tue, 20 Nov 2007 06:05
23 lines
1747 bytes
�������� ����������� wrote:
> Can you tell me how i use the Extract in a Date Field?
> I want to sum by a month. Please write an example

select EXTRACT(month from TRAN_DATE), sum(GRAND_TOTAL)
from TRAN_TABLE
where TRAN_DATE >= '1/1/2005'
group by EXTRACT(month from TRAN_DATE)

but this is bad, because it adds all Januaries together (unless, of 
course, this is what you want; you might want to see which month does 
better!). So, to make it like I think you want it, simply change it as 
follows:

select EXTRACT(year from TRAN_DATE), EXTRACT(month from TRAN_DATE), 
sum(GRAND_TOTAL)
from SALES_TRAN
where TRAN_DATE >= '1/1/2005'
group by EXTRACT(year from TRAN_DATE), EXTRACT(month from TRAN_DATE)

Hope this helps,

Loren sZendre
Technical Details
Message-ID: <4742788d$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <47427718@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 114a0e,ba5f46b06493ddc2
X-Google-Attributes: gid114a0e,public,usenet
X-Google-Language: ENGLISH,ASCII
Date: Mon, 19 Nov 2007 22:05:29 -0800
From: Zoren Lendry <zorenlendry@yahoo.com>
User-Agent: Thunderbird 2.0.0.6 (Windows/20070728)
MIME-Version: 1.0
Newsgroups: borland.public.interbase.sql
Subject: Re: Extract use
References: <47427718@newsgroups.borland.com>
In-Reply-To: <47427718@newsgroups.borland.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit
NNTP-Posting-Host: 64.185.103.219
Message-ID: <4742788d$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1195538573 64.185.103.219 (19 Nov 2007 22:02:53 -0700)
Lines: 23
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail