Quantcast
Channel: SCN: Message List - SAP SQL Anywhere
Viewing all articles
Browse latest Browse all 2182

Re: SELECT when one column might be NULL

$
0
0
CREATE TABLE TransactionRows (   ArticleId INTEGER,   LotNumber INTEGER,   LineId    INTEGER,   Qty       INTEGER );

INSERT TransactionRows VALUES ( 1, NULL, 5, 55 )
INSERT TransactionRows VALUES ( 1, 10,   6, 66 );
INSERT TransactionRows VALUES ( 1, 20,   7, 77 );
COMMIT;

BEGIN 
DECLARE @ArticleId INTEGER;
DECLARE @LotNumber INTEGER;
SET @ArticleId = 1;
SET @LotNumber = 10;
SELECT T.LineId,T.Qty
FROM TransactionRows AS T
WHERE T.ArticleId = @ArticleId 
  AND ( T.LotNumber IS NULL OR T.LotNumber = @LotNumber );
END;

LineId,Qty
5,55
6,66

Viewing all articles
Browse latest Browse all 2182

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>