on 2024 Jan 15 2:26 AM
Hello Experts
We have a UDF called work bins in the production order and I am trying to write a query that will show me production orders with duplicate work bins
But I am getting the below error, can someone please point me in the right direction
SELECT
T0.[DocNum],
T0.[DueDate],
T0.[ItemCode],
T0.[ProdName],
T0.[PlannedQty],
T0.[Status],
T0.[U_WORKBIN]
FROM OWOR T0
WHERE T0.[U_WORKBIN] >1
ORDER BY T0.[U_INE_WORKBIN], T0.[DocNum]<br>
Regards
Rah
Request clarification before answering.
Hi Rah,
Apparently T0.[U_WORKBIN] is of type nvarchar, and you have records in the OWOR table where it contains a none-numeric value. When you try to do a calculation type comparison (>1), the sql parser cannot tell if the value WRK00280 is larger than 1.
Regards,
Johan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Rah,
Please give this a try:
SELECT
T0.[DocNum],
T0.[DueDate],
T0.[ItemCode],
T0.[ProdName],
T0.[PlannedQty],
T0.[Status],
T0.[U_WORKBIN]
FROM OWOR T0
WHERE T0.[U_WORKBIN] IN (select x.[U_WORKBIN]
from OWOR x
group by x.[U_WORKBIN]
having COUNT(x.[DocNum]) > 1)
ORDER BY T0.[U_INE_WORKBIN], T0.[DocNum]<br>Regards,
Johan
| User | Count |
|---|---|
| 22 | |
| 16 | |
| 13 | |
| 6 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.