Example:
CREATE TABLE #tmp
(
id int PRIMARY KEY,
name varchar(20),age int
)
GO
INSERT #tmp(id, name, age) VALUES (1, 'John',20)
INSERT #tmp(id, name, age) VALUES (2, 'Dan',40)GO
declare @minage int,
@maxage intSELECT
@minage = min(age),
@maxage = max(age)
FROM
#tmp
select
@minage as minage, @maxage as maxage
drop table #tmp