復原通知我有一個store
表具有productName
,productNumber
,storedInBranch
,blockNumber
,quantity
,notifyIn
。SQL查詢來從存儲表
如果quantity
小於notifyIn
它會通知我,我想下面的查詢:
select * from store
where (quantity < notifyIn) AND (notify > 0)
這完美的作品,但由於一個產品可以存儲在多個blockNumbers
它通知我即使量的產品並不比notifyin
少,
例如:
productName = monitor, productNumber=123, storedInBranch=kenya, blocknumber=5b, quantity=5, notifyin=4
productName = monitor, productNumber=123, storedInBranch=kenya, blocknumber=<b>1a</b>, quantity=5, notifyin=4
所以ABOV e查詢返回的結果都是低的,我想要做的就是總計quantity
(5 + 5)和notifyIn
4.
考慮進一步標準化數據庫模式以刪除重複字段。你可以提取產品到自己的表 – useyourillusiontoo
也提取分支到一個表與相關的分支信息,如通知限制 – useyourillusiontoo