B842/121:2 情感与智商 李立 7-80142-671-1 48 HT146250
B842/121:2 情感与智商 李立 7-80142-671-1 48 HT146256
B842/121:2 情感与智商 李立 7-80142-671-1 48 HT146257
这个并成什么?
B842/121:2 情感与智商 李立 7-80142-671-1 48 HT146256
B842/121:2 情感与智商 李立 7-80142-671-1 48 HT146257
这个并成什么?
INSERT @TB
SELECT 'G78/81', N'父母教育孩子的39堂课', N'禾田', '7-5064-3201-3', 28, 'HT143073' UNION ALL
SELECT 'G78/81', N'父母教育孩子的39堂课', N'禾田', '7-5064-3201-3', 28, 'HT143074' UNION ALL
SELECT 'G78/81', N'父母教育孩子的39堂课', N'禾田', '7-5064-3201-3', 28, 'HT143075' UNION ALL
SELECT 'B821/407', N'心灵圣经', N'韩湘君', '7-80110-580-X', 19.8, 'HT142971' UNION ALL
SELECT 'B821/407', N'心灵圣经', N'韩湘君', '7-80110-580-X', 19.8, 'HT142972' UNION ALL
SELECT 'B842/121:2', N'情感与智商', N'李立', '7-80142-671-1', 48, 'HT146250' UNION ALL
SELECT 'B842/121:2', N'情感与智商', N'李立', '7-80142-671-1', 48, 'HT146256' UNION ALL
SELECT 'B842/121:2', N'情感与智商', N'李立', '7-80142-671-1', 48, 'HT146257' UNION ALL
SELECT 'B83/57', N'风流与幽默', N'刘安诺', '7-80084-702-0', 39.6, 'HT146251' UNION ALL
SELECT 'B83/57', N'风流与幽默', N'刘安诺', '7-80084-702-0', 39.6, 'HT146252'SELECT [Fgetnumber],[title],[author],[isbn],MIN([price]) AS [price],MIN([barcord])+'-'+RIGHT(MAX([barcord]),2) AS [barcord],SUM([price]) AS [price]
FROM @TB
GROUP BY [Fgetnumber],[title],[author],[isbn]
/*
Fgetnumber title author isbn price barcord price
---------- ----------- ------ ------------- ----------- ----------- -----------
B821/407 心灵圣经 韩湘君 7-80110-580-X 19 HT142971-72 38
B83/57 风流与幽默 刘安诺 7-80084-702-0 39 HT146251-52 78
B842/121:2 情感与智商 李立 7-80142-671-1 48 HT146250-57 144
G78/81 父母教育孩子的39堂课 禾田 7-5064-3201-3 28 HT143073-75 84(4 row(s) affected)
*/
(select min(barcordort) from tb_center where fgetnumber=t.fgetnumber)+'-'+
(select right(max(barcordort),2) from tb_center where fgetnumber=t.fgetnumber),
(select count(barcordort) from tb_center where fgetnumber=t.fgetnumber),
(select sum(price) from tb_center where fgetnumber=t.fgetnumber)
from tb_center t
那个N是什么意思?
还有如果有几万条记录也有一条条UNIONALL吗?