将数据类型 nvarchar 转换为数字时出错,但我不知道为什么
Error converting data type nvarchar to numeric but I have no idea why
我 运行 我创建了一个查询,但我收到 "Error converting data type nvarchar to numeric" 错误以及 "Warning: Null value is eliminated by an aggregate or other SET operation." 但我不知道为什么,因为我没有转换任何东西。
这是我的查询:
SELECT DISTINCT TOP 1000
O.Date_Entered
,O.Company_Code
,O.Division_Code
,O.Customer_Purchase_Order_Number
,O.Control_Number
,O.Customer_Number
,P.PickTicket_Number
,sh.PACKSLIP
,Accellos_Download
,Accellos_Allocated
,Accellos_Waved
,Accellos_Label
,Accellos_Last_Pick
,Accellos_Rating
,Accellos_Shipped
,Accellos_Upload
FROM [JMNYC-AMTDB].[AMTPLUS].[dbo].Orders o (nolock)
LEFT JOIN [JMNYC-AMTDB].[AMTPLUS].[dbo].PickTickets P (nolock)
on O.Company_Code = P.Company_Code
and O.Division_Code = P.Division_Code
and O.Control_Number = P.Control_Number
LEFT JOIN [JMDNJ-ACCELSQL].[A1WAREHOUSE].[dbo].SHIPHIST sh (nolock) ON o.Customer_Purchase_Order_Number = sh.cust_po
LEFT JOIN (
SELECT
Packslip
,max( case when Action like 'DNLOAD' then Date_Time end) as Accellos_Download
,max( case when Action like 'ALLOC' then Date_Time end) as Accellos_Allocated
,max( case when Action like 'WAVEORDER' then Date_Time end) as Accellos_Waved
,max( case when Action like 'NEWLABEL' then Date_Time end) as Accellos_Label
,max( case when Action like 'EOL_LSTP' then Date_Time end) as Accellos_Last_Pick
,max( case when Action like 'RATED' then Date_Time end) as Accellos_Rating
,max( case when Action like 'SHIPPED' then Date_Time end) as Accellos_Shipped
,max( case when Action like 'UPLOAD' then Date_Time end) as Accellos_Upload
FROM(
SELECT DISTINCT
Packslip
,Date_Time
,Action
from [JMDNJ-ACCELSQL].[A1Warehouse].[dbo].[RF_LOG2] RL (nolock)
)RLTS
group by Packslip
)RLTSS on Coalesce(sh.PACKSLIP, P.pickticket_number) = RLTSS.PACKSLIP
这是 RF_LOG2 Table
的示例
+--------------------------------------+----------+----------+---------------------------------------------------------------------------------------------------------+--------+----------+----------+----------+----------+-----------+---------------------+----------------------+----------------------+--------------------+------------+----------+--------+--------+----------+------------------+------------+----------+----------+
| ROWID | PACKSLIP | BINLABEL | EXTENDED | TERMID | USERID | ACTION | QUANTITY | Q_SCALER | TOTLABEL | REFERENCE2 | REFERENCE3 | DATE_TIME | DATE_CREAT | CLIENTNAME | TENANTID | PO_NUM | SERIAL | LOCATION | LICENSE_PLATE | PURGE_FLAG | PACKSIZE | UPLOADED |
+--------------------------------------+----------+----------+---------------------------------------------------------------------------------------------------------+--------+----------+----------+----------+----------+-----------+---------------------+----------------------+----------------------+--------------------+------------+----------+--------+--------+----------+------------------+------------+----------+----------+
| BC5A92B0-F347-4E27-80C5-49798E1B6B75 | 90214801 | PICK | | 0 | | DNLOAD | 0.000000 | 0 | | E. Keith DuBose | l:1 u:1 | 20190726 13:15:29.87 | 0x00000000207E9F1E | 09 | | | | | | 1 | 1.000000 | 0 |
| 3564B24F-1AA9-42A4-83A4-D14151395CED | 90214801 | | | 0 | jsac | ALLOCORD | 0.000000 | 0 | | Allocated | READY TO WAVE | 20190726 13:25:54.51 | 0x00000000207E4672 | 09 | | | | | | 1 | 1.000000 | 0 |
| 0E5B3952-2BD4-4035-A645-1C024B8D3F10 | 90214801 | | | 0 | jsac | ALLOC | 0.000000 | 0 | | Release SWOG | | 20190726 13:25:54.54 | 0x00000000207F14C6 | 09 | | | | | | 1 | 1.000000 | 0 |
| 09575559-EB27-4CDB-8B35-56F741F779E1 | 90214801 | | | 0 | jsac | WAVEORDR | 0.000000 | 0 | | Wave:2392 | RF Picking | 20190726 15:05:31.71 | 0x00000000207EFE60 | 09 | | | | | | 1 | 1.000000 | 0 |
| 61B21B11-D638-4AA2-A94A-25B54650EBAD | 90214801 | | | 0 | | EOL_PRNT | 0.000000 | 0 | | New Carton | 00008139850296299650 | 20190726 15:06:03.79 | 0x00000000207E5A7D | 09 | | | | | | 1 | 1.000000 | 0 |
| 7B46FD91-A30D-4D92-A9E9-6024630D2710 | 90214801 | | | 0 | RFBASE | NEWLABEL | 0.000000 | 0 | 109629965 | 029629965 | | 20190726 15:06:03.80 | 0x00000000207E480E | 09 | | | | | | 1 | 1.000000 | 0 |
| 042D7D42-1D08-4926-AF5B-005868924302 | 90214801 | 3F88082A | 910B2307NSZ99000 /09 | 0 | LSAB | PICK_LP | 1.000000 | 1 | 109629965 | LP picking | | 20190726 15:55:58.92 | 0x00000000207F04F4 | 09 | | | | | 910B2307NSZ99000 | 1 | 1.000000 | 0 |
| 21711DE4-6119-47C0-B3F0-1A0AB816A679 | 90214801 | 3F88082A | 910B2307NSZ99000 /09 | 0 | LSAB | MOVE-OUT | 1.000000 | -1 | | 1 Packs of 1.000000 | via PICKING | 20190726 15:55:58.94 | 0x00000000207E32CC | 09 | | | | | | 1 | 1.000000 | 0 |
| E0D5C819-DC3C-4E21-9857-25476432A057 | 90214801 | 3F88082A | 910B2307NSZ99000 /09 | 0 | LSAB | PICKDETL | 1.000000 | -1 | 109629965 | | | 20190726 15:55:58.95 | 0x00000000207E239A | 09 | | | | | | 1 | 1.000000 | 0 |
| 20D981C1-CE83-459F-9D7A-1784CC215856 | 90214801 | | | 0 | LSAB | EOL_LSCP | 0.000000 | 0 | | Last Pick In Carton | 00008139850296299650 | 20190726 15:55:58.97 | 0x00000000207E07FE | 09 | | | | | | 1 | 1.000000 | 0 |
| CDBCBD5B-9DC7-4FE5-91C9-7C409EA4C2D9 | 90214801 | | | 0 | LSAB | PICKORDR | 0.000000 | 0 | | | | 20190726 15:55:58.97 | 0x00000000207F1CEE | 09 | | | | | | 1 | 1.000000 | 0 |
| DD637317-640E-4A8D-A8DB-9C2C587BA217 | 90214801 | 3F88082A | 910B2307NSZ99000 /09 | 0 | LSAB | PICKLINE | 1.000000 | -1 | | 1 | | 20190726 15:55:58.97 | 0x00000000207E8F55 | 09 | | | | | | 1 | 1.000000 | 0 |
| EE4D734C-8CCE-4C73-B133-C024D79A6054 | 90214801 | | | 0 | LSAB | EOL_LSTP | 0.000000 | 0 | | LAST PICK COMPLETED | 2 | 20190726 15:55:58.97 | 0x00000000207F516E | 09 | | | | | | 1 | 1.000000 | 0 |
| 06204BC1-87B1-4340-9712-C8996388B550 | 90214801 | | | 0 | BACKGRND | RATED | 0.000000 | 0 | 109629965 | 109629965 ACT99 | SHP1563345 | 20190729 08:30:39.86 | 0x000000002089F080 | 09 | | | | | | 1 | 1.000000 | 0 |
| 48759371-8B78-4901-8BE4-749FA55E1D40 | 90214801 | | | 0 | BACKGRND | EOL_SSYS | 0.000000 | 0 | | ShipSys Confirm | | 20190729 08:30:39.89 | 0x0000000020896EF1 | 09 | | | | | | 1 | 1.000000 | 0 |
| 904BF8C6-794D-4288-A594-22BA93A31095 | 90214801 | | | 0 | BACKGRND | SHIPPED | 0.000000 | 0 | | USPS PM | SHP1563345 | 20190729 08:30:39.90 | 0x000000002087F9F3 | 09 | | | | | | 1 | 1.000000 | 0 |
| ECA102C8-B7C4-46D3-A844-FBD0CFE79413 | 90214801 | | | 0 | sdob | SUSPEND | 0.000000 | 0 | | | | 20190729 09:45:40.12 | 0x00000000208922D8 | 09 | | | | | | 1 | 1.000000 | 0 |
| 867A7B87-5AB2-4EE7-8FDC-7175D406C0F0 | 90214801 | | | 0 | sdob | UNSUSPND | 0.000000 | 0 | | | | 20190729 10:07:56.88 | 0x00000000208A0AF5 | 09 | | | | | | 1 | 1.000000 | 0 |
| E5FB157B-9837-4DA8-B5D0-9A605603FD60 | 90214801 | | | 0 | sdob | SHIPCOMP | 0.000000 | 0 | | | ship_order() | 20190729 11:42:20.30 | 0x000000002089D1FD | 09 | | | | | | 1 | 1.000000 | 0 |
| 37D4B782-1184-4F91-913B-F1BA251740DF | 90214801 | | | 0 | sdob | SHIPPED | 0.000000 | 0 | | USPS PM | SHP1563345 | 20190729 11:42:20.32 | 0x000000002088482F | 09 | | | | | | 1 | 1.000000 | 0 |
| 4FDE75F7-D98B-451E-A106-0C9F29BADEE1 | 90214801 | | | 0 | sdob | EOL_EXTN | 0.000000 | 0 | | External Process | | 20190729 11:42:20.33 | 0x0000000020897E4A | 09 | | | | | | 1 | 1.000000 | 0 |
| C41D73C8-385A-4547-A684-7CEA1B7CE9DB | 90214801 | PICK | | 0 | C# | UPLOAD | 0.000000 | 0 | | E. Keith DuBose | | 20190729 11:43:45.66 | 0x00000000208A1D2F | | | | | | | 1 | 1.000000 | 0 |
+--------------------------------------+----------+----------+---------------------------------------------------------------------------------------------------------+--------+----------+----------+----------+----------+-----------+---------------------+----------------------+----------------------+--------------------+------------+----------+--------+--------+----------+------------------+------------+----------+----------+
我想做的是获取订单每个部分的时间戳。所以它是什么时候创建的,什么时候被拾取的,等等。我希望这些信息按订单水平显示。此外,它仅在 运行 后崩溃了大约 5 分钟。
警告 Warning: Null value is eliminated by an aggregate or other SET operation
发生是因为您在 max() 中执行的 Date_Time 的值包含 NULL 值。
这个错误恐怕是Coalesce(sh.PACKSLIP, P.pickticket_number)
造成的。您应该检查类型并将其中一个转换为与另一个具有相同的类型。根据 table 的提示,您附加的它们都应该是数值。
要避免警告,您可以使用以下选项。
设置ANSI_WARNINGS关闭
我 运行 我创建了一个查询,但我收到 "Error converting data type nvarchar to numeric" 错误以及 "Warning: Null value is eliminated by an aggregate or other SET operation." 但我不知道为什么,因为我没有转换任何东西。
这是我的查询:
SELECT DISTINCT TOP 1000
O.Date_Entered
,O.Company_Code
,O.Division_Code
,O.Customer_Purchase_Order_Number
,O.Control_Number
,O.Customer_Number
,P.PickTicket_Number
,sh.PACKSLIP
,Accellos_Download
,Accellos_Allocated
,Accellos_Waved
,Accellos_Label
,Accellos_Last_Pick
,Accellos_Rating
,Accellos_Shipped
,Accellos_Upload
FROM [JMNYC-AMTDB].[AMTPLUS].[dbo].Orders o (nolock)
LEFT JOIN [JMNYC-AMTDB].[AMTPLUS].[dbo].PickTickets P (nolock)
on O.Company_Code = P.Company_Code
and O.Division_Code = P.Division_Code
and O.Control_Number = P.Control_Number
LEFT JOIN [JMDNJ-ACCELSQL].[A1WAREHOUSE].[dbo].SHIPHIST sh (nolock) ON o.Customer_Purchase_Order_Number = sh.cust_po
LEFT JOIN (
SELECT
Packslip
,max( case when Action like 'DNLOAD' then Date_Time end) as Accellos_Download
,max( case when Action like 'ALLOC' then Date_Time end) as Accellos_Allocated
,max( case when Action like 'WAVEORDER' then Date_Time end) as Accellos_Waved
,max( case when Action like 'NEWLABEL' then Date_Time end) as Accellos_Label
,max( case when Action like 'EOL_LSTP' then Date_Time end) as Accellos_Last_Pick
,max( case when Action like 'RATED' then Date_Time end) as Accellos_Rating
,max( case when Action like 'SHIPPED' then Date_Time end) as Accellos_Shipped
,max( case when Action like 'UPLOAD' then Date_Time end) as Accellos_Upload
FROM(
SELECT DISTINCT
Packslip
,Date_Time
,Action
from [JMDNJ-ACCELSQL].[A1Warehouse].[dbo].[RF_LOG2] RL (nolock)
)RLTS
group by Packslip
)RLTSS on Coalesce(sh.PACKSLIP, P.pickticket_number) = RLTSS.PACKSLIP
这是 RF_LOG2 Table
的示例+--------------------------------------+----------+----------+---------------------------------------------------------------------------------------------------------+--------+----------+----------+----------+----------+-----------+---------------------+----------------------+----------------------+--------------------+------------+----------+--------+--------+----------+------------------+------------+----------+----------+
| ROWID | PACKSLIP | BINLABEL | EXTENDED | TERMID | USERID | ACTION | QUANTITY | Q_SCALER | TOTLABEL | REFERENCE2 | REFERENCE3 | DATE_TIME | DATE_CREAT | CLIENTNAME | TENANTID | PO_NUM | SERIAL | LOCATION | LICENSE_PLATE | PURGE_FLAG | PACKSIZE | UPLOADED |
+--------------------------------------+----------+----------+---------------------------------------------------------------------------------------------------------+--------+----------+----------+----------+----------+-----------+---------------------+----------------------+----------------------+--------------------+------------+----------+--------+--------+----------+------------------+------------+----------+----------+
| BC5A92B0-F347-4E27-80C5-49798E1B6B75 | 90214801 | PICK | | 0 | | DNLOAD | 0.000000 | 0 | | E. Keith DuBose | l:1 u:1 | 20190726 13:15:29.87 | 0x00000000207E9F1E | 09 | | | | | | 1 | 1.000000 | 0 |
| 3564B24F-1AA9-42A4-83A4-D14151395CED | 90214801 | | | 0 | jsac | ALLOCORD | 0.000000 | 0 | | Allocated | READY TO WAVE | 20190726 13:25:54.51 | 0x00000000207E4672 | 09 | | | | | | 1 | 1.000000 | 0 |
| 0E5B3952-2BD4-4035-A645-1C024B8D3F10 | 90214801 | | | 0 | jsac | ALLOC | 0.000000 | 0 | | Release SWOG | | 20190726 13:25:54.54 | 0x00000000207F14C6 | 09 | | | | | | 1 | 1.000000 | 0 |
| 09575559-EB27-4CDB-8B35-56F741F779E1 | 90214801 | | | 0 | jsac | WAVEORDR | 0.000000 | 0 | | Wave:2392 | RF Picking | 20190726 15:05:31.71 | 0x00000000207EFE60 | 09 | | | | | | 1 | 1.000000 | 0 |
| 61B21B11-D638-4AA2-A94A-25B54650EBAD | 90214801 | | | 0 | | EOL_PRNT | 0.000000 | 0 | | New Carton | 00008139850296299650 | 20190726 15:06:03.79 | 0x00000000207E5A7D | 09 | | | | | | 1 | 1.000000 | 0 |
| 7B46FD91-A30D-4D92-A9E9-6024630D2710 | 90214801 | | | 0 | RFBASE | NEWLABEL | 0.000000 | 0 | 109629965 | 029629965 | | 20190726 15:06:03.80 | 0x00000000207E480E | 09 | | | | | | 1 | 1.000000 | 0 |
| 042D7D42-1D08-4926-AF5B-005868924302 | 90214801 | 3F88082A | 910B2307NSZ99000 /09 | 0 | LSAB | PICK_LP | 1.000000 | 1 | 109629965 | LP picking | | 20190726 15:55:58.92 | 0x00000000207F04F4 | 09 | | | | | 910B2307NSZ99000 | 1 | 1.000000 | 0 |
| 21711DE4-6119-47C0-B3F0-1A0AB816A679 | 90214801 | 3F88082A | 910B2307NSZ99000 /09 | 0 | LSAB | MOVE-OUT | 1.000000 | -1 | | 1 Packs of 1.000000 | via PICKING | 20190726 15:55:58.94 | 0x00000000207E32CC | 09 | | | | | | 1 | 1.000000 | 0 |
| E0D5C819-DC3C-4E21-9857-25476432A057 | 90214801 | 3F88082A | 910B2307NSZ99000 /09 | 0 | LSAB | PICKDETL | 1.000000 | -1 | 109629965 | | | 20190726 15:55:58.95 | 0x00000000207E239A | 09 | | | | | | 1 | 1.000000 | 0 |
| 20D981C1-CE83-459F-9D7A-1784CC215856 | 90214801 | | | 0 | LSAB | EOL_LSCP | 0.000000 | 0 | | Last Pick In Carton | 00008139850296299650 | 20190726 15:55:58.97 | 0x00000000207E07FE | 09 | | | | | | 1 | 1.000000 | 0 |
| CDBCBD5B-9DC7-4FE5-91C9-7C409EA4C2D9 | 90214801 | | | 0 | LSAB | PICKORDR | 0.000000 | 0 | | | | 20190726 15:55:58.97 | 0x00000000207F1CEE | 09 | | | | | | 1 | 1.000000 | 0 |
| DD637317-640E-4A8D-A8DB-9C2C587BA217 | 90214801 | 3F88082A | 910B2307NSZ99000 /09 | 0 | LSAB | PICKLINE | 1.000000 | -1 | | 1 | | 20190726 15:55:58.97 | 0x00000000207E8F55 | 09 | | | | | | 1 | 1.000000 | 0 |
| EE4D734C-8CCE-4C73-B133-C024D79A6054 | 90214801 | | | 0 | LSAB | EOL_LSTP | 0.000000 | 0 | | LAST PICK COMPLETED | 2 | 20190726 15:55:58.97 | 0x00000000207F516E | 09 | | | | | | 1 | 1.000000 | 0 |
| 06204BC1-87B1-4340-9712-C8996388B550 | 90214801 | | | 0 | BACKGRND | RATED | 0.000000 | 0 | 109629965 | 109629965 ACT99 | SHP1563345 | 20190729 08:30:39.86 | 0x000000002089F080 | 09 | | | | | | 1 | 1.000000 | 0 |
| 48759371-8B78-4901-8BE4-749FA55E1D40 | 90214801 | | | 0 | BACKGRND | EOL_SSYS | 0.000000 | 0 | | ShipSys Confirm | | 20190729 08:30:39.89 | 0x0000000020896EF1 | 09 | | | | | | 1 | 1.000000 | 0 |
| 904BF8C6-794D-4288-A594-22BA93A31095 | 90214801 | | | 0 | BACKGRND | SHIPPED | 0.000000 | 0 | | USPS PM | SHP1563345 | 20190729 08:30:39.90 | 0x000000002087F9F3 | 09 | | | | | | 1 | 1.000000 | 0 |
| ECA102C8-B7C4-46D3-A844-FBD0CFE79413 | 90214801 | | | 0 | sdob | SUSPEND | 0.000000 | 0 | | | | 20190729 09:45:40.12 | 0x00000000208922D8 | 09 | | | | | | 1 | 1.000000 | 0 |
| 867A7B87-5AB2-4EE7-8FDC-7175D406C0F0 | 90214801 | | | 0 | sdob | UNSUSPND | 0.000000 | 0 | | | | 20190729 10:07:56.88 | 0x00000000208A0AF5 | 09 | | | | | | 1 | 1.000000 | 0 |
| E5FB157B-9837-4DA8-B5D0-9A605603FD60 | 90214801 | | | 0 | sdob | SHIPCOMP | 0.000000 | 0 | | | ship_order() | 20190729 11:42:20.30 | 0x000000002089D1FD | 09 | | | | | | 1 | 1.000000 | 0 |
| 37D4B782-1184-4F91-913B-F1BA251740DF | 90214801 | | | 0 | sdob | SHIPPED | 0.000000 | 0 | | USPS PM | SHP1563345 | 20190729 11:42:20.32 | 0x000000002088482F | 09 | | | | | | 1 | 1.000000 | 0 |
| 4FDE75F7-D98B-451E-A106-0C9F29BADEE1 | 90214801 | | | 0 | sdob | EOL_EXTN | 0.000000 | 0 | | External Process | | 20190729 11:42:20.33 | 0x0000000020897E4A | 09 | | | | | | 1 | 1.000000 | 0 |
| C41D73C8-385A-4547-A684-7CEA1B7CE9DB | 90214801 | PICK | | 0 | C# | UPLOAD | 0.000000 | 0 | | E. Keith DuBose | | 20190729 11:43:45.66 | 0x00000000208A1D2F | | | | | | | 1 | 1.000000 | 0 |
+--------------------------------------+----------+----------+---------------------------------------------------------------------------------------------------------+--------+----------+----------+----------+----------+-----------+---------------------+----------------------+----------------------+--------------------+------------+----------+--------+--------+----------+------------------+------------+----------+----------+
我想做的是获取订单每个部分的时间戳。所以它是什么时候创建的,什么时候被拾取的,等等。我希望这些信息按订单水平显示。此外,它仅在 运行 后崩溃了大约 5 分钟。
警告 Warning: Null value is eliminated by an aggregate or other SET operation
发生是因为您在 max() 中执行的 Date_Time 的值包含 NULL 值。
这个错误恐怕是Coalesce(sh.PACKSLIP, P.pickticket_number)
造成的。您应该检查类型并将其中一个转换为与另一个具有相同的类型。根据 table 的提示,您附加的它们都应该是数值。
要避免警告,您可以使用以下选项。
设置ANSI_WARNINGS关闭