|
--surroundings
create table TestTable
(
Number varchar(6),
Name varchar(10),
Other varchar(50)
)
insert into TestTable select '10000','Beijing','A Dou will fall with the wind'
insert into TestTable select '10000','河北','sfsaadf'
insert into TestTable select '10000','Shanxi', '23424234'
insert into TestTable select '10001','eat','safa with the wind'
insert into TestTable select '10001','sleep','haha'
insert into TestTable select '10005','Don't think about it', '2234234'
insert into TestTable select '10006','Hurry up', '3424234'
insert into TestTable select '10007','Faith with the wind','Speed disperse each other'
insert into TestTable select '10007', '324','With the wind'
--Statement
select
Order = (select count(1) from TestTable where number = a. number and name <= a. name),
Number, name, other
from TestTable a
order by number, order
--result
Sequence Number Name Other
----------- ------ ---------- ----------------------- ---------------------------
1 10000 Beijing, A Dou falls with the wind
2 10000 Hebei sfsaadf
3 10000 Shanxi 23424234
1 10001 Eat with the wind
2 10001 sleep haha
1 10005 Don't think about it 2234234
1 10006 hurry up 3424234
1 10007 324 Follow the wind
2 10007 Follow the wind to spread the speed
(The number of rows affected is 9 rows) |
|