Get column name which has the max value in a row sql

前端 未结 4 877
孤城傲影
孤城傲影 2021-01-20 22:47

I have a a table in my database where I store categories for newsarticles and each time a user reads an article it increments the value in the associated column. Like this:<

4条回答
  •  青春惊慌失措
    2021-01-20 23:25

    PL/SQL, maybe? Set user_id, query your table, store the returned row in an nx2 array of column names and values (where n is the number of columns) and sort the array based on the values.

    Of course, the correct thing to do is redesign your database in the manner that @octern suggests.

提交回复
热议问题