Home > Net >  SQL Query how to make Net amount with combined tables if there is a null value in Discount amount
SQL Query how to make Net amount with combined tables if there is a null value in Discount amount

Time:10-26

I have a Price table and a Discount table, currently I am using this to calculate the Net price between the two:

RS_PCL.Price-RS_DISC.[Disc Amt] AS Net

However, I do a Left join from the PCL table to the Discount table because there are certain items which don't have discounts. Is it possible to make this field also include the normal Price if the Discount amount is null?

(Currently, if the discount amount is null, it just leaves Net blank/null, I'd like to include the price with no discount removed)

CodePudding user response:

You can use Nz:

RS_PCL.Price-Nz(RS_DISC.[Disc Amt],0) AS Net
  • Related