Ask a Question related to PHP Development, Design and Development.

  1. #1

    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


    Albert Ahtenberg Guest

  2. Similar Questions and Discussions

    1. Is this a MySQL Query bug?
      I wrote a SQL script in MySQL Query, and saved it as script.sql, but when I executed it in windows command line "mysql -h localhost -u root...
    2. MySQL Query Cache Not Working: MySQL 5 / Windows XP
      Please excuse this post if you've already read it on mailing.database.mysql - i just discovered these other groups. future posts will be...
    3. MYSQL query: AND OR?
      This will probably sound stupid. How would you do a MYSQL query that was to evaluate if either condition A or B was meet? And if so, in what...
    4. MySql query help
      Hey, I am trying to retrive information from a database using the 'Mysql_fetch_assoc' function, but the problem is.. it is just one row of data...
    5. Query log for mySQL?
      Is there a simple way to create a query log for mySQL? I've been asked^h^h^h^h^h told to add a layer of auditing on an existing application. It's...
  3. #2

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

    Steven James Samuel Stapleton Guest

  4. #3

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

    Albert Ahtenberg Guest

  5. #4

    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
    [url]http://mike.vorefamily.net/ohmywoodness[/url] <-Custom Woodworking
    [url]http://mike.vorefamily.net/thewoodenradio[/url] <-The weblog
    Mike Vore Guest

  6. #5

    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
    > [url]http://mike.vorefamily.net/ohmywoodness[/url] <-Custom Woodworking
    > [url]http://mike.vorefamily.net/thewoodenradio[/url] <-The weblog

    Albert Ahtenberg Guest

  7. #6

    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:
    Pedro Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139