sql - What's an elegant way to find the minimum value in each row of a table? -


i've got table has row per product, , price product has on ten different merchants. i'd see minimum price each product has among different merchants.

in excel easy, because min() function there works on set of cells, whether they're arranged horizontally or vertically. however, min() in sql acts on columns, i'd able find cheapest price merchant 1 had across products, etc.

is there elegant way obtain minimum price each row? (are there olap functions this, or problem have approached using loop?)

in postgresql, can do:

select least(price1, price2, price3, ..) products     

least gives minimum value of list of values. it's non-aggregate version of min.


Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -