Board index » delphi » Grouping by month
John Birch
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
|
John Birch
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Grouping by month
I'm trying to create in report using Delphi 3 using the built in Quick
Reports package. The report selects items from a table by date, and I want to summarise John Birch |
Tom
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Grouping by monthQuoteJohn Birch wrote in message <36B97F2F.1...@{*word*269}.net>... if you are working on an SQL Server, you got the possibility of creating views that seperates your date field into 3 integer fields, _day, _month and _year (use the SQL datetime functions from your server, on MS-SQL e.g. it's the datepart function). If you got the view, you can make a group by month, like select sum(ammount) from tableX group by _month... NB: in MS-SQL you can directly make a group by Datepart(m,Datefield), so no Tom |
John Birc
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Grouping by monthQuoteTom wrote: it. |
Doug Maure
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Grouping by monthI am also in need of the exact same thing. I am using D4 With all updates and Pdox 7 tables. Thanks in advance -- |
Steve Koters
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Grouping by monthOn Thu, 04 Feb 1999 15:09:34 +0000, John Birch <john.bi...@{*word*269}.net> wrote: [...] Quote>Thanks Tom, unfortunately its a Paradox table. Sorry I didn't mention because local SQL does not allow a GROUP BY clause to be based on a derived value, such as the EXTRACT function when used to get a date column's month portion. You can produce a result set using local SQL in a slightly different way. To do so, you would need to connect one monthly summary SELECT query for each month (i.e., 12 SELECT queries) with UNION clauses. To summarize one month, using the sample Paradox table ORDERS.DB, in this SELECT "01", SUM(O."AMOUNTPAID") To summarize on a monthly basis for the same year, repeat the same SELECT SELECT "01", SUM(O."AMOUNTPAID") ////////////////////////////////////////////////////////////////////////// |
Johan Berrevoet
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Grouping by monthThis should work : SELECT EXTRACT(MONTH FROM O."SALEDATE") AS m, SUM(O."AMOUNTPAID") |
Steve Koters
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Grouping by monthOn Fri, 05 Feb 1999 08:58:27 +0100, Johan Berrevoets Quote<Berre...@btmaa.bel.alcatel.be> wrote: used for dBASE and Paradox tables. At least this is true as of version 5.02 of the BDE (the latest). For instance, the SQL statement below using the sample Paradox table SELECT EXTRACT(MONTH FROM O.SaleDate) AS M, SUM(O.AmountPaid) ...results in the error "Invalid field name", referring to M as used in the ////////////////////////////////////////////////////////////////////////// |
chuck4..
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Grouping by monthMr. Birch- I ran into the exact same situation you did. Here's the workaround I came up with. First, run a query like this: SELECT Extract(MONTH from FuelingDate) currmth, Extract(YEAR from The SELECT statement containing the EXTRACT command is the important part of STR(qryRMVMonthly.currmth) + STR(qryRMVMonthly.curryr) Converting these values to a string first and then concatenating them is PS there is a plethora of information on Quick Reports at the In article <36B97F2F.1...@{*word*269}.net>, Quotejohn.bi...@{*word*269}.net wrote: -----------== Posted via Deja News, The Discussion Network ==---------- |