From: Muhammad Bilal on 30 Mar 2010 14:47 Hi. I want to have a min value form a row instead of a column. Let erp Name col1 col2 col3 col4 coll4 5585 john 101 255 245 514 98 6697 tom 222 457 987 700 12 i want to get the min from row 1 and row 2 from column clo1, clo2 , clo3 col4 , c0l4. Regards, Muhammad Bilal
From: Plamen Ratchev on 30 Mar 2010 16:33 Try this: SELECT MIN(value) AS min_value FROM Foo UNPIVOT (value FOR col IN (col1, col2, col3, col4, col5)) AS U; SELECT name, MIN(value) AS min_value FROM Foo UNPIVOT (value FOR col IN (col1, col2, col3, col4, col5)) AS U GROUP BY name; -- Plamen Ratchev http://www.SQLStudio.com
|
Pages: 1 Prev: 'Studio Management Report Services' Next: Service pack 3 and Cluster |