TrialByError TrialByError - 1 month ago 20
SQL Question

SQL query with lowest ID

Given the linked data:

How would I query the name of the tag with the lowest id that has a post count equal to the median post count?


Not completly sure what your asking but im guesing something like this. This will return the column "TagName" in the row with the lowest "Id" with the "Count" field equeal to the avarage of the column "Count".

SELECT TOP(1) TagName 
FROM TableName
WHERE Count = ( 
                SELECT AVG(Count)
                FROM TableName
                GROUP BY Count