Mysql query

This is a discussion on Mysql query within the PHP Language forums, part of the PHP Programming Forums category; Hi, I have a database with a date field. And I would like to see the report grouped by a ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 06-27-2003
Albert Ahtenberg
 
Posts: n/a
Default Mysql query

Hi,

I have a database with a date field. And I would like to see the report
grouped by a ceratin month and year, how can I do that without multiple
queries?

Albert Ahtenberg


Reply With Quote
  #2 (permalink)  
Old 06-27-2003
Steven James Samuel Stapleton
 
Posts: n/a
Default Re: Mysql query

What format is the date field stored in?

Is there a day, month, and year field (separate)?
Is it a timestamp?
Is it something else?

-Jim Stapleton

"Albert Ahtenberg" <donotcontact@this.address> wrote in message
news:bdhud4$tev$1@tabloid.uwaterloo.ca...
> Hi,
>
> I have a database with a date field. And I would like to see the report
> grouped by a ceratin month and year, how can I do that without multiple
> queries?
>
> Albert Ahtenberg
>
>



Reply With Quote
  #3 (permalink)  
Old 06-28-2003
Albert Ahtenberg
 
Posts: n/a
Default Re: Mysql query

It is the MySql DATE type. looks like (DD-MM-YYYY).

"Steven James Samuel Stapleton" <stapleton.41@mps.ohio-state.edu> wrote in
message news:mcgHx12drhfu@ohstpy...
> What format is the date field stored in?
>
> Is there a day, month, and year field (separate)?
> Is it a timestamp?
> Is it something else?
>
> -Jim Stapleton
>
> "Albert Ahtenberg" <donotcontact@this.address> wrote in message
> news:bdhud4$tev$1@tabloid.uwaterloo.ca...
> > Hi,
> >
> > I have a database with a date field. And I would like to see the report
> > grouped by a ceratin month and year, how can I do that without multiple
> > queries?
> >
> > Albert Ahtenberg
> >
> >

>
>



Reply With Quote
  #4 (permalink)  
Old 06-28-2003
Mike Vore
 
Posts: n/a
Default Re: Mysql query


First get a real email address if you want real replies.

On Fri, 27 Jun 2003 20:54:25 -0400, Albert <donotcontact@this.address> wrote:
> It is the MySql DATE type. looks like (DD-MM-YYYY).

^^^^^^^^^^
This isn't a MySQL date format.


select * from mydatabase where datefield like "2003-07%";

This works for me.


>
> "Steven James Samuel Stapleton" <stapleton.41@mps.ohio-state.edu> wrote in
> message news:mcgHx12drhfu@ohstpy...
>> What format is the date field stored in?
>>
>> Is there a day, month, and year field (separate)?
>> Is it a timestamp?
>> Is it something else?
>>
>> -Jim Stapleton
>>
>> "Albert Ahtenberg" <donotcontact@this.address> wrote in message
>> news:bdhud4$tev$1@tabloid.uwaterloo.ca...
>> > Hi,
>> >
>> > I have a database with a date field. And I would like to see the report
>> > grouped by a ceratin month and year, how can I do that without multiple
>> > queries?
>> >
>> > Albert Ahtenberg
>> >
>> >

>>
>>

>
>



--
Michael Vore, W3CCV M-ASA [Ka8]; WHIRL, ABC; CAW, CW, AAW
http://mike.vorefamily.net/ohmywoodness <-Custom Woodworking
http://mike.vorefamily.net/thewoodenradio <-The weblog
Reply With Quote
  #5 (permalink)  
Old 06-29-2003
Albert Ahtenberg
 
Posts: n/a
Default Re: Mysql query

Mike,

Regarding my Email address, I got so much spam when I posted my Email
address on this forum so I decided not to. Besides, I can't see the
relevancy of my Email to this at all.

Now, what you suggest will choose all the records with the date July/03.
What I need is not to have them selected by the date but grouped by a
certain date. I will give you an example. Suppose I have a 'date' field and
a 'sum' field. What I need is a report about the total sum in each month.
And I wonder what is the most simple way to do it.

Regards,
Albert Ahtenberg

"Mike Vore" <mvore@ix.netcom.cam> wrote in message
news:slrnbfr1ln.sqp.mvore@snowmass.mystic.ct...
>
> First get a real email address if you want real replies.
>
> On Fri, 27 Jun 2003 20:54:25 -0400, Albert <donotcontact@this.address>

wrote:
> > It is the MySql DATE type. looks like (DD-MM-YYYY).

> ^^^^^^^^^^
> This isn't a MySQL date format.
>
>
> select * from mydatabase where datefield like "2003-07%";
>
> This works for me.
>
>
> >
> > "Steven James Samuel Stapleton" <stapleton.41@mps.ohio-state.edu> wrote

in
> > message news:mcgHx12drhfu@ohstpy...
> >> What format is the date field stored in?
> >>
> >> Is there a day, month, and year field (separate)?
> >> Is it a timestamp?
> >> Is it something else?
> >>
> >> -Jim Stapleton
> >>
> >> "Albert Ahtenberg" <donotcontact@this.address> wrote in message
> >> news:bdhud4$tev$1@tabloid.uwaterloo.ca...
> >> > Hi,
> >> >
> >> > I have a database with a date field. And I would like to see the

report
> >> > grouped by a ceratin month and year, how can I do that without

multiple
> >> > queries?
> >> >
> >> > Albert Ahtenberg
> >> >
> >> >
> >>
> >>

> >
> >

>
>
> --
> Michael Vore, W3CCV M-ASA [Ka8]; WHIRL, ABC; CAW, CW, AAW
> http://mike.vorefamily.net/ohmywoodness <-Custom Woodworking
> http://mike.vorefamily.net/thewoodenradio <-The weblog



Reply With Quote
  #6 (permalink)  
Old 06-30-2003
Pedro
 
Posts: n/a
Default Re: Mysql query

Albert Ahtenberg wrote:
>> select * from mydatabase where datefield like "2003-07%";


maybe
select year(datefield), month(datefield), sum(valuefield)
from table
group by year(datefield), month(datefield)

HTH

--
"Yes, I'm positive."
"Are you sure?"
"Help, somebody has stolen one of my electrons!"
Two atoms are talking:
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 10:48 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0