www.webdeveloper.com
Results 1 to 3 of 3

Thread: union query

Hybrid View

  1. #1
    Join Date
    Nov 2008
    Posts
    62

    union query

    Hi!
    I have a problem with a query in Mysql.
    In my table stored access for period.

    My table cloumns are
    -account_id (primaty key)
    -years (primaty key)
    -month (primaty key)
    -access_number

    account_id_A 2012 03 12
    account_id_A 2012 04 15
    account_id_A 2013 04 10
    account_id_B 2012 03 12
    account_id_B 2012 04 15
    account_id_B 2013 03 7

    I need to create a query to extract:
    account_id, total number of access in 2012, total number of access in 2013.
    I'm unable to prepare query in a correct way.
    thanks!

  2. #2
    Join Date
    Feb 2012
    Location
    youTUBE
    Posts
    234

    Group by...

    This will work for you:
    Code:
    select account_id, years , month , SUM(access_numbe)
    from MyTable
    GROUP by account_id, years

  3. #3
    Join Date
    Apr 2013
    Posts
    135
    I have suggestion that
    code:
    select account_id, years from MyTable GROUP by account_id, years

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles