select ISBN, name, sum(number) as number
from (select SUBSTRING(ISBN,1,3) as ISBN, name, number from table_name) as A
group by ISBN,name
是不是MS SQL Server? 不是的话, 你浪费了我的时间!
from (select SUBSTRING(ISBN,1,3) as ISBN, name, number from table_name) as A
group by ISBN,name
是不是MS SQL Server? 不是的话, 你浪费了我的时间!
From table_name
group by substr(isbn,1,3)in Oracle.
from
(
Select substr(isbn,1,3) isbn,max(name) name,sum(number) sum_n
From table_name
group by substr(isbn,1,3)
union
select '合计' isbn, ' ' name, sum(number) sum_n
from table_name
)
order by isbn