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