Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2003
    Location
    Nicosia, Cyprus
    Posts
    6

    Unhappy Unanswered: Seems like it'll take lots of time while i join the club :(

    Hello all!
    Well i come up with somehow another problem with queries in Postgre.
    When i pass the following query:
    SELECT ip_networks.chunk_id,ip_networks.ip_mask, SUM(ip_allocations.ip_mask) FROM ip_networks,ip_allocations WHERE ip_allocations.chunk_id = ip_networks.chunk_id AND ip_networks.ip_mask >= '15';

    i get this:
    ERROR: Attribute ip_networks.chunk_id must be GROUPed or used in an aggregate function

    So the question comes out how do i rewrite this query so as to get what i want?

  2. #2
    Join Date
    Feb 2003
    Location
    Denmark
    Posts
    7

    Re: Seems like it'll take lots of time while i join the club :(

    Originally posted by ixremedy
    Hello all!
    Well i come up with somehow another problem with queries in Postgre.
    When i pass the following query:
    SELECT ip_networks.chunk_id,ip_networks.ip_mask, SUM(ip_allocations.ip_mask) FROM ip_networks,ip_allocations WHERE ip_allocations.chunk_id = ip_networks.chunk_id AND ip_networks.ip_mask >= '15';

    i get this:
    ERROR: Attribute ip_networks.chunk_id must be GROUPed or used in an aggregate function

    So the question comes out how do i rewrite this query so as to get what i want?
    Code:
     
    SELECT ip_networks.chunk_id,ip_networks.ip_mask, SUM(ip_allocations.ip_mask)
    FROM ip_networks,ip_allocations
    WHERE ip_allocations.chunk_id = ip_networks.chunk_id AND ip_networks.ip_mask >= '15'
    GROUP BY ip_networks.chunk_id,ip_networks.ip_mask

Posting Permissions

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