Ask a Question related to ASP Database, Design and Development.
-
@yahoo@com #1
Create Report Based on Monthly Intervals
I hope one of you SQL Guru's can assist me on this one.
I want to create a report in my ASP app (SQL 2000 backend). This report will show the number of orders flagged as 'Complete', grouped by month.
For example, If I 'run' the report, I should see:
Jan 2003 : 37 Orders
Feb 2003 : 43 Orders
....
June 2004 : 18 Orders
July 2004 : 55 Orders
The first month would be the 'Oldest' in the DB and the last would be the most recent. The dates are stored in a Date field in the DB called 'OrderDate'.
I cannot think my way out of this one, so I thought I would ask.
XWEB
@yahoo@com Guest
-
Using Report Builder as a client based tool?
Hi, I am trying to work out if it's feasible to give report builder to clients to build their own bespoke reports. The issue seems to revolve... -
PHP include based on viewer country? Monthly service? Isthere an alternative?
Hi All - looking for opinions. I need to have some pages on my site come up with an 'advert' based on the viewers country. I know there are... -
Monthly Report
Having troubles defining a script for finding and printing sales for the month. Thanks Barry -
Create a Report
Yes, I know that, what I mean is how to make or which is the PHP code so I get the report like a Crystal Report for example "David Robley"... -
Create a Report from a Database
I'm using MySQL and PHP for building a website, however now I need to create something like this: {Title} {Description} {Zone1} Detail Zone1 -
Ken Schaefer #2
Re: Create Report Based on Monthly Intervals
A bit messy, but I think it does what you want (watch for wrapping!)
SELECT
CAST(DateName(mm, OrderDate) AS VarChar) + ', ' + CAST(DatePart(yyyy,
OrderDate) AS varChar) AS OrderSummaryDate,
COUNT(*),
DatePart(yyyy, OrderDate),
DatePart(mm, OrderDate)
FROM
Orders
WHERE
Flagged = 'Completed'
GROUP BY
CAST(DateName(mm, OrderDate) as VarChar) + ', ' + Cast(DatePart(yyyy,
OrderDate) as varChar),
DatePart(yyyy, OrderDate),
DatePart(mm, OrderDate)
ORDER BY
DatePart(yyyy, OrderDate),
DatePart(mm, OrderDate)
HTH
Cheers
Ken
"@yahoo@com" <""xweb10\"@yahoo@com"> wrote in message
news:u9yYJhgbEHA.3804@TK2MSFTNGP10.phx.gbl...will show the number of orders flagged as 'Complete', grouped by month.> I hope one of you SQL Guru's can assist me on this one.
>
> I want to create a report in my ASP app (SQL 2000 backend). This reportmost recent. The dates are stored in a Date field in the DB called> For example, If I 'run' the report, I should see:
>
> Jan 2003 : 37 Orders
> Feb 2003 : 43 Orders
> ...
> June 2004 : 18 Orders
> July 2004 : 55 Orders
>
> The first month would be the 'Oldest' in the DB and the last would be the
'OrderDate'.>
> I cannot think my way out of this one, so I thought I would ask.
>
> XWEB
Ken Schaefer Guest
-
Ken Schaefer #3
Re: Create Report Based on Monthly Intervals
Actually, this is a better solution (less load on your DB server):
SELECT
DatePart(mm, OrderDate),
DatePart(yyyy, OrderDate),
COUNT(*)
FROM
Orders
WHERE
Flagged = 'Completed'
GROUP BY
DatePart(mm, OrderDate),
DatePart(yyyy, OrderDate)
ORDER BY
DatePart(yyyy, OrderDate),
DatePart(mm, OrderDate)
and then you use MonthName in VBScript/ASP to change the month number to a
name.
Cheers
Ken
"@yahoo@com" <""xweb10\"@yahoo@com"> wrote in message
news:u9yYJhgbEHA.3804@TK2MSFTNGP10.phx.gbl...will show the number of orders flagged as 'Complete', grouped by month.> I hope one of you SQL Guru's can assist me on this one.
>
> I want to create a report in my ASP app (SQL 2000 backend). This reportmost recent. The dates are stored in a Date field in the DB called> For example, If I 'run' the report, I should see:
>
> Jan 2003 : 37 Orders
> Feb 2003 : 43 Orders
> ...
> June 2004 : 18 Orders
> July 2004 : 55 Orders
>
> The first month would be the 'Oldest' in the DB and the last would be the
'OrderDate'.>
> I cannot think my way out of this one, so I thought I would ask.
>
> XWEB
Ken Schaefer Guest
-
PW #4
Re: Create Report Based on Monthly Intervals
Select month(OrderDate) as myMonth, year(OrderDate) as myYear, count(*) as
myCount
From Orders
Where Flagged = 'Completed'
Group by myYear, myMonth
Order by myYear, myMonth
PW Guest
-
@yahoo@com #5
Re: Create Report Based on Monthly Intervals
Thank you both for the tips. I will try them out.
XWEB
PW wrote:> Select month(OrderDate) as myMonth, year(OrderDate) as myYear, count(*) as
> myCount
> From Orders
> Where Flagged = 'Completed'
> Group by myYear, myMonth
> Order by myYear, myMonth
>
>
>
>
>
>
>
>@yahoo@com Guest
-
@yahoo@com #6
Re: Create Report Based on Monthly Intervals
Ken,
Your solution was perfect. Thank you.
Now, to push a bit further :)
What if I wanted to get the order totals for those indivudual months as well? The field name is "OrderTotal"
XWEB
Ken Schaefer wrote:
> Actually, this is a better solution (less load on your DB server):
>
> SELECT
> DatePart(mm, OrderDate),
> DatePart(yyyy, OrderDate),
> COUNT(*)
> FROM
> Orders
> WHERE
> Flagged = 'Completed'
> GROUP BY
> DatePart(mm, OrderDate),
> DatePart(yyyy, OrderDate)
> ORDER BY
> DatePart(yyyy, OrderDate),
> DatePart(mm, OrderDate)
>
> and then you use MonthName in VBScript/ASP to change the month number to a
> name.
>
> Cheers
> Ken
>
>
> "@yahoo@com" <""xweb10\"@yahoo@com"> wrote in message
> news:u9yYJhgbEHA.3804@TK2MSFTNGP10.phx.gbl...
>>>>I hope one of you SQL Guru's can assist me on this one.
>>
>>I want to create a report in my ASP app (SQL 2000 backend). This report
> will show the number of orders flagged as 'Complete', grouped by month.
>>>>For example, If I 'run' the report, I should see:
>>
>>Jan 2003 : 37 Orders
>>Feb 2003 : 43 Orders
>>...
>>June 2004 : 18 Orders
>>July 2004 : 55 Orders
>>
>>The first month would be the 'Oldest' in the DB and the last would be the
> most recent. The dates are stored in a Date field in the DB called
> 'OrderDate'.
>>>>I cannot think my way out of this one, so I thought I would ask.
>>
>>XWEB
>
>@yahoo@com Guest
-
Ken Schaefer #7
Re: Create Report Based on Monthly Intervals
Add
SUM(OrderTotal)
Cheers
Ken
"@yahoo@com" <""xweb10\"@yahoo@com"> wrote in message
news:uAQQGItbEHA.1764@TK2MSFTNGP10.phx.gbl...well? The field name is "OrderTotal"> Ken,
>
> Your solution was perfect. Thank you.
>
> Now, to push a bit further :)
>
> What if I wanted to get the order totals for those indivudual months asa>
> XWEB
>
> Ken Schaefer wrote:
>> > Actually, this is a better solution (less load on your DB server):
> >
> > SELECT
> > DatePart(mm, OrderDate),
> > DatePart(yyyy, OrderDate),
> > COUNT(*)
> > FROM
> > Orders
> > WHERE
> > Flagged = 'Completed'
> > GROUP BY
> > DatePart(mm, OrderDate),
> > DatePart(yyyy, OrderDate)
> > ORDER BY
> > DatePart(yyyy, OrderDate),
> > DatePart(mm, OrderDate)
> >
> > and then you use MonthName in VBScript/ASP to change the month number tothe> > name.
> >
> > Cheers
> > Ken
> >
> >
> > "@yahoo@com" <""xweb10\"@yahoo@com"> wrote in message
> > news:u9yYJhgbEHA.3804@TK2MSFTNGP10.phx.gbl...
> >> >> >>I hope one of you SQL Guru's can assist me on this one.
> >>
> >>I want to create a report in my ASP app (SQL 2000 backend). This report
> > will show the number of orders flagged as 'Complete', grouped by month.
> >> >>For example, If I 'run' the report, I should see:
> >>
> >>Jan 2003 : 37 Orders
> >>Feb 2003 : 43 Orders
> >>...
> >>June 2004 : 18 Orders
> >>July 2004 : 55 Orders
> >>
> >>The first month would be the 'Oldest' in the DB and the last would be> >
> > most recent. The dates are stored in a Date field in the DB called
> > 'OrderDate'.
> >> >> >>I cannot think my way out of this one, so I thought I would ask.
> >>
> >>XWEB
> >
> >
Ken Schaefer Guest
-



Reply With Quote

