Mysql query

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Albert Ahtenberg

    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


  • Steven James Samuel Stapleton

    #2
    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@t his.address> wrote in message
    news:bdhud4$tev $1@tabloid.uwat erloo.ca...[color=blue]
    > 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
    >
    >[/color]


    Comment

    • Albert Ahtenberg

      #3
      Re: Mysql query

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

      "Steven James Samuel Stapleton" <stapleton.41@m ps.ohio-state.edu> wrote in
      message news:mcgHx12drh fu@ohstpy...[color=blue]
      > 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@t his.address> wrote in message
      > news:bdhud4$tev $1@tabloid.uwat erloo.ca...[color=green]
      > > 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
      > >
      > >[/color]
      >
      >[/color]


      Comment

      • Mike Vore

        #4
        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@t his.address> wrote:[color=blue]
        > It is the MySql DATE type. looks like (DD-MM-YYYY).[/color]
        ^^^^^^^^^^
        This isn't a MySQL date format.


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

        This works for me.

        [color=blue]
        >
        > "Steven James Samuel Stapleton" <stapleton.41@m ps.ohio-state.edu> wrote in
        > message news:mcgHx12drh fu@ohstpy...[color=green]
        >> 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@t his.address> wrote in message
        >> news:bdhud4$tev $1@tabloid.uwat erloo.ca...[color=darkred]
        >> > 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
        >> >
        >> >[/color]
        >>
        >>[/color]
        >
        >[/color]


        --
        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

        Comment

        • Albert Ahtenberg

          #5
          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.netco m.cam> wrote in message
          news:slrnbfr1ln .sqp.mvore@snow mass.mystic.ct. ..[color=blue]
          >
          > First get a real email address if you want real replies.
          >
          > On Fri, 27 Jun 2003 20:54:25 -0400, Albert <donotcontact@t his.address>[/color]
          wrote:[color=blue][color=green]
          > > It is the MySql DATE type. looks like (DD-MM-YYYY).[/color]
          > ^^^^^^^^^^
          > This isn't a MySQL date format.
          >
          >
          > select * from mydatabase where datefield like "2003-07%";
          >
          > This works for me.
          >
          >[color=green]
          > >
          > > "Steven James Samuel Stapleton" <stapleton.41@m ps.ohio-state.edu> wrote[/color][/color]
          in[color=blue][color=green]
          > > message news:mcgHx12drh fu@ohstpy...[color=darkred]
          > >> 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@t his.address> wrote in message
          > >> news:bdhud4$tev $1@tabloid.uwat erloo.ca...
          > >> > Hi,
          > >> >
          > >> > I have a database with a date field. And I would like to see the[/color][/color][/color]
          report[color=blue][color=green][color=darkred]
          > >> > grouped by a ceratin month and year, how can I do that without[/color][/color][/color]
          multiple[color=blue][color=green][color=darkred]
          > >> > queries?
          > >> >
          > >> > Albert Ahtenberg
          > >> >
          > >> >
          > >>
          > >>[/color]
          > >
          > >[/color]
          >
          >
          > --
          > 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[/color]


          Comment

          • Pedro

            #6
            Re: Mysql query

            Albert Ahtenberg wrote:[color=blue][color=green]
            >> select * from mydatabase where datefield like "2003-07%";[/color][/color]

            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:

            Comment

            Working...