Finding 2 highest value in a row using mysql -


i have numbers 5, 3, 1, 8, 7 in row in mysql table , each number belongs column.

how find 2 highest number , find sum?

assuming table name coltb , has following successive columns

col1,col2,col3,col4,col5 

you can issue following statement 2 highest numbers:

select col1 coltb union select col2 coltb union select col3 coltb union select col4 coltb union select col5 coltb order col1 desc limit 2; 

Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -