SQLTeam.com | Weblogs | Forums

Select date based on min value in another column

sql2012

#1

I have 2 columns in a single table. One column are all date values the other column's data are all integers. How can I get the date from the date column based on the minimum value in the column of integers? Thanks for all and any help.


#2
SELECT	IntegerColumn, DateColumn
FROM
(
	SELECT	[T_RowNumber] = ROW_NUMBER()
			OVER
			(
--				PARTITION BY OptionalPartitionColumn(s)
				ORDER BY IntegerColumn DESC
			),
		IntegerColumn,
		DateColumn
	FROM YourTable
) AS T
WHERE	T_RowNumber = 1
-- ORDER BY SomeColumn

#3

Thank you very much. Works like a charm and thank your for your fast response.