请教一句SQL语句
表A如下:
DepotId DepotTitle DepotCode
1001 一楼 1001
1002 一楼一组 10011001
1003 一楼二组 10011002
表B如下:
ProId ProNum DepotId DepotCode
1 1 1002 10011001
2 1 1003 10011002
要求实现如下:
DepotCode DepotTitle DepotCount
1001 一楼 2
10011001 一楼一组 1
10011002 一楼二组 1
注:DepotCount是表B中ProNum的合计
------解决方案--------------------try
Select
A.DepotCode,
A.DepotTitle,
SUM(B.ProNum) As DepotCount
From
A
Inner Join
B
On B.DepotCode Like A.DepotCode + '% '
Group By
A.DepotCode,
A.DepotTitle