Hi! I used below script, but I want order by Id and Age.
DECLARE @InfoTable AS TABLE(Id INT IDENTITY(1,1),LastName VARCHAR(25),Name VARCHAR(25),Birthday date,Address VARCHAR(50))
INSERT INTO @InfoTable VALUES('Pulodov','Rustam','1987-12-22','city Dushanbe')
INSERT INTO @InfoTable VALUES('Soliev','Firuzjon','1988-06-16','city Hisor')
INSERT INTO @InfoTable VALUES('Sharipov','Sadriddin','1991-12-08','city Dushanbe')
INSERT INTO @InfoTable VALUES('Yakubi','Hasanzod','1991-05-15','city Dushanbe')
INSERT INTO @InfoTable VALUES('Sayfurov','Karomatullo','1980-05-07','city Dushanbe')
INSERT INTO @InfoTable VALUES('Asrori','Yatim','1978-02-06','city Dushanbe')
select row_number() over(order by Id) AS Id, LastName, Name, Birthday, CONVERT(VARCHAR,CONVERT(INT,DATEDIFF(DD,Birthday,GETDATE())/365.25))Age, Address from @InfoTable order by Id, CONVERT(VARCHAR,CONVERT(INT,DATEDIFF(DD,Birthday,GETDATE())/365.25))
Output result:
Id
|
LastName
|
Name
|
Birthday
|
Age
|
Address
|
1
|
Sharipov
|
Sadriddin
|
1991-12-08
|
25
|
city Dushanbe
|
2
|
Yakubi
|
Hasanzod
|
1991-05-15
|
26
|
city Dushanbe
|
3
|
Pulodov
|
Rustam
|
1987-12-22
|
29
|
city Dushanbe
|
4
|
Soliev
|
Firuzjon
|
1988-06-16
|
29
|
city Hisor
|
5
|
Sayfurov
|
Karomatullo
|
1980-05-07
|
37
|
city Dushanbe
|
6
|
Asrori
|
Yatim
|
1978-02-06
|
39
|
city Dushanbe
|