我有2个表,表A:
CategoryId |数量
2018-11-02T05:31:22.7214141Z ##[section]Starting: Deploy Azure App Service
2018-11-02T05:31:22.7468470Z
==============================================================================
2018-11-02T05:31:22.7468805Z Task : Azure App Service Deploy
2018-11-02T05:31:22.7468901Z Description : Update Azure App Services on Windows, Web App on Linux with built-in images or Docker containers, ASP.NET, .NET Core, PHP, Python or Node.js based Web applications, Function Apps, Mobile Apps, API applications, Web Jobs using Web Deploy / Kudu REST APIs
2018-11-02T05:31:22.7469033Z Version : 3.4.13
2018-11-02T05:31:22.7469089Z Author : Microsoft Corporation
2018-11-02T05:31:22.7469173Z Help : [More information](https://aka.ms/azurermwebdeployreadme)
2018-11-02T05:31:22.7469246Z
==============================================================================
2018-11-02T05:31:23.6141335Z Got connection details for Azure App Service:'myproject'
2018-11-02T05:31:27.9431753Z ##[error]Error: No package found with specified pattern: D:\a\r1\a\**\*.zip
2018-11-02T05:31:29.9576685Z Successfully added release annotation to the Application Insight : myproject
2018-11-02T05:31:33.0440055Z Successfully updated deployment History at https://xxxxxxxxx.scm.azurewebsites.net/api/deployments/4154xxxxxx957
2018-11-02T05:31:33.0615049Z ##[section]Finishing: Deploy Azure App Service
表B:
SaleId | CategoryId |保留数量
1 | 10
2 | 15
我要显示这样的结果(将两个表连接起来):
CategoryId |数量保留数量
1 | 1 | 2
2 | 1 | 1
3 | 2 | 5
我怎么可能做到这一点?谢谢。
答案 0 :(得分:2)
使用SUM
和GROYP BY
SELECT C.CategoryId,C.Qty,SUM(S.QtyReserved) AS QtyReserved
FROM tableA AS C
INNER JOIN tableB AS S ON C.CategoryId = S.CategoryId
GROUP BY C.CategoryId,C.Qty