Re: SQL Query Question - HELP!

From: BP Margolin <bpmargo_at_attglobal.net>
Date: Wed, 26 Mar 2003 21:40:17 -0500
Message-ID: <3e8264be 2_at_news1.prserv.net>


The best way to request assistance with an SQL query is by posting (simplified) table schemas (CREATE TABLEs), sample data (INSERTs), and the results you want using the sample data.

You should also be aware that it can be counter-productive to post to three different database forums, as it is possible that a query that works in one of the databases, will fail in the others because each RDBMS tends to have proprietary (i.e., non-portable) extensions to the ANSI SQL standard.

For SQL Server, you might try something like:

select datename(mm, date column) + ' ' + cast(datepart(yy, datepart) as varchar) as Month,

          count(*) as Total
from ...
group by datename(mm, date column) + ' ' + cast(datepart(yy, datepart) as varchar)
where date column >= '20020101'

Without table schemas and sample data, this query is posted untested.



BP Margolin
Please reply only to the newsgroups.
When posting, inclusion of SQL (CREATE TABLE ..., INSERT ..., etc.) which
can be cut and pasted into Query Analyzer is appreciated.

"MAL" <d dood_at_hotmail.com> wrote in message news:68fa75f2.0303261502.19f64fcf_at_posting.google.com...
> Here's what I have to do:
>
> How many total requests by month from 1/1/2002? 13 rows
>
> Each request has an individual ID column and each row has a date that
> it was entered into the DB. I need the results of the query to look as
> such:
>
> Month Total
> January 2002 12
> February 2002 12
> March 2002 12
>
> etc...
>
> I am trying to figure out how to take the date info and just turn it
> into a month and count the number of requests per month.
>
> Any ideas gang?
>
> Thanks!
Received on Thu Mar 27 2003 - 03:40:17 CET

Original text of this message