我试图通过汇总桥表TransactionRecords的结果来更新Transactions表中的SubTotal字段。以下是我的表格。
| Transaction |
| ID | SubTotal |
| 1 | ??? |
| 2 | ??? |
| 3 | ??? |
| TransactionRecords |
| TransactionID | ProductID | QTY | SalePrice |
| 1 | 10 | 4 | 19.99 |
| 2 | 5 | 8 | 9.99 |
| 2 | 3 | 12 | 14.99 |
我想要的是Transaction.SubTotal等于TransactionRecords.SalePrice * TransactionRecords.QTY,其中TransactionRecords.TransactionID等于Transaction.ID
此查询:
select TransactionID, sum(UnitPrice * QuantitySold)
from TransactionRecord
group by TransactionID;
向我提供每笔交易中的每笔交易和销售金额,以及我希望交易表中包含的相应ID的值。
答案 0 :(得分:0)
试试这个:
import matplotlib
import matplotlib.pyplot as plt
import seaborn as sns
from matplotlib.colors import LogNorm
fig = plt.figure()
ax1 = fig.add_subplot(1,1,1)
ax1.set_title("P-value")
Z1 = pos_spearmanr['pval']
X = pos_spearmanr['X']
Y = pos_spearmanr['Y']
im = ax1.scatter(X,
Y,
edgecolors=None,
c=Z1,
norm=LogNorm(),
cmap=plt.get_cmap('bwr'), alpha=0.2)
ax1.set_xlabel('X')
ax1.set_ylabel('Y')
ax1.set_xlim(0, 1)
ax1.set_ylim(0, 1)
cbar = fig.colorbar(im,ax=ax1)