Monday, July 19, 2010

In sql what query would you use to determine the most popular (the column name that appears the most frequentl

In sql what query would you use to determine the most popular (the column name that appears the most frequently) column name in the tables of your database?

In sql what query would you use to determine the most popular (the column name that appears the most frequentl
You'll need an SQL version great enough to use sub-queries.





SELECT %26lt;fieldname%26gt;, count(%26lt;fieldname%26gt;) AS number FROM (SELECT %26lt;fieldname%26gt; FROM %26lt;table%26gt;) AS %26lt;tableAlias%26gt; GROUP BY %26lt;fieldname%26gt; ORDER BY number DESC





I derived that query from the source I have linked (which features a more complex situation), and it works.


No comments:

Post a Comment