Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 MIN across multiple columns with a GROUP BY

Author  Topic 

angarakiran777
Starting Member

3 Posts

Posted - 2015-01-13 : 23:58:11
Hi,

How to get the lowest U.Price along with FX and Rate.

ID-U.Price-FX-Rate

1280 19.1196 EUR 3.85
1280 46.2462 USD 3.63
1280 6.32 RM 1.00

Required output.

ID-U.Price-FX-Rate

1280 6.32 RM 1.00

nagino
Yak Posting Veteran

75 Posts

Posted - 2015-01-14 : 00:54:11
SELECT TOP 1
ID, [U.Price], FX, Rate
FROM YourTable
ORDER BY [U.Price] ASC

-------------------------------------
From Japan
Sorry, my English ability is limited.
Go to Top of Page

bandi
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2015-01-14 : 02:11:38
SELECT * FROM ( SELECT ID, [U.Price], FX, Rate, ROW_NUMBER() OVER(PARTITION BY ID ORDER BY [U.Price] ASC ) RowNum
FROM YourTable
) Temp
WHERE RowNum=1

--
Chandu
Go to Top of Page
   

- Advertisement -