Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2006
    Posts
    1

    Unanswered: Tricky Group By question

    Hello all! I'm trying to get the Group By working with a semi-complex mysql command. This following command works properly:
    (SELECT
    worth.PropStName,
    worth.BuyerLastName,
    worth.ListingAgent as a1,
    worth.SellingAgent,
    worth.CloseDate,
    worthusers.name,
    worth.Price
    FROM
    worthusers
    INNER JOIN worth ON (worthusers.name = worth.SellingAgent)
    WHERE
    (datediff(date_sub(curdate(), Interval 1 year), worth.CloseDate) < 0))

    UNION

    (SELECT
    worth.PropStName,
    worth.BuyerLastName,
    worth.ListingAgent,
    worth.SellingAgent,
    worth.CloseDate,
    worthusers.name,
    worth.Price
    FROM
    worthusers
    INNER JOIN worth ON (worthusers.name = worth.ListingAgent)
    WHERE
    (datediff(date_sub(curdate(), Interval 1 year), worth.CloseDate) < 0))

    I'd like to group the output by the worthusers.name field and i've tried to alias it AS A1 and then GROUP BY A1 at the end of the entire statement but something is amiss...

    Any help would be appreciated!
    Thanks!
    G

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    sounds like you want ORDER BY, not GROUP BY
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

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