Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,589 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I have the below query, but the AND pd.FROMLOC <> 'DMS' does not work if the column has {null} is there a workaround?
SELECT pd.wavekey, pd.orderkey, o.externorderkey, pd.pickdetailkey, pd.status, pd.fromloc, pd.loc, pd.sku, pd.qty, pd.adddate, SUBSTR(o.c_zip,1,3), O.SUSR4, od.cartonbreak
FROM sprtict.pickdetail pd
Join sprtict.ORDERS O on O.ORDERKEY = PD.ORDERKEY
Join sprtict.ORDERDETAIL OD on OD.ORDERKEY = O.ORDERKEY and od.ORDERLINENUMBER = pd.ORDERLINENUMBER
WHERE(PD.adddate BETWEEN (TRUNC(SYSDATE-1) + 21/24) AND (TRUNC(SYSDATE) + 21/24))
AND od.cartonbreak NOT IN ('FLOORPICK', 'LIFTPICK', 'STRINGERS')
AND pd.FROMLOC <> 'DMS'
AND pd.LOC <> 'DMS'
AND O.SUSR4 = '3P01'
AND pd.wavekey = '0001520762'
AND o.externorderkey = 'SP000044662873'
Fixed, and nvl(pd.fromloc, 'NullFROMLOC') <> 'DMS'
I nvl is an Oracle command. This is a MS SQL Server forum.
However, I suggest you read this:
https://www.red-gate.com/simple-talk/sql/t-sql-programming/how-to-get-nulls-horribly-wrong-in-sql-server/