Not sure how to explain this, as I have only basic SQL knowledge. I need help with some logic to signal a user when a unique string is referenced more than once in a composite primary key.
A table I use contains a composite primary key which ties a unique “ItemCode” to a repeating “WarehouseCode”. The “QuantityOnHand” column lists how much we have of an item in each warehouse:
_____PK_______
| |
ItemCode | WarehouseCode | QuantityOnHand
---------------------------------------------
001 A 100
001 B 500
002 A 600
003 B 250
etc.
How do I “signal” (create a boolean value?) when ItemCode 001 is in two separate warehouses?
The end result is a crystal report which somehow alerts the user when an item’s total quantity is split between two warehouses.
Thanks
Utilise GROUP BY and HAVING. For example this query will return a list of ItemCodes and a count of how many warehouses they are in where that count is greater than 1.