TrialByError TrialByError - 1 year ago 101
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?

Answer Source

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
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download