Having a bit of trouble understanding how the request alias works in postgresql. I have the following:
SELECT DISTINCT robber.robberid, nickname, Count(accomplices.robberid) AS count1 FROM robber INNER JOIN accomplices ON accomplices.robberid = robber.robberid GROUP BY robber.robberid, robber.nickname ORDER BY Count(accomplices.robberid) DESC; robberid | nickname | count1
I can rename the column "count1" with the as command, but it seems like I cannot refer to this again in the query? I am trying to include the HAVING command at the end of this query to request only objects whose number is less than half the maximum value.
This is homework, but I am not asking for an answer just a pointer to how I can include the column count1 in another sentence.
Can anyone help?
source share