create table tb(
ID int,
book_name varchar(20),
attorney varchar(20),
price int)
insert tb select 1,'语文','小张',13
insert tb select 1,'语文','小李',14
insert tb select 1,'数学','小王',15
insert tb select 1,'数学','小张',14
select book_name=case when attorney=(select top 1 attorney from tb where book_name=a.book_name) then book_name else '' end,
attorney,price
from tb a
drop table tb
/*
book_name
attorney
price
-------------------- -------------------- -----------
语文
小张
13
小李
14
数学
小王
15
小张
14
(所影响的行数为 4 行)
*/