I have two SQL Server database tables.
columns: SalesOrderNumber, OrderQty
columns: SerialNumber, SalesOrderNumber (Sales Order to which the Serial Number is assigned)
I want to return a list of Sales Order Numbers where the Order Qty is less than the assigned Serial Numbers for that Sales Order. Basically, I need a list of Sales Orders that do not have enough Serial Numbers assigned to fill the order.
Serial Numbers can only be assigned to one Sales Order and Sales Orders can be assigned to more than one Serial Number.
Any help with the T-SQL to make this happen?