I have a table - Sales
| Id | TypeNr | TypeId | Price | Quantity |
|---|---|---|---|---|
| 1 | 0 | 10 | 4.32 | 120 |
| 2 | 1 | 20 | 2.38 | 0 |
Desired output:
| Id | TypeNr | TypeId | Price | Quantity | Description |
|---|---|---|---|---|---|
| 1 | 0 | 10 | 4.32 | 120 | Blue Shirt |
| 2 | 1 | 20 | 2.38 | 0 | 20% Discount |
If TypeNr is 0 then I need to make a join to the Products table and pull the name associated with the TypeId.
If TypeNr is 1 then I need to make a join to the Discounts table and pull the discount associated with tye TypeId.
-- I have tried several methods with IFs / CASE/ELSE but my knowledge of SQL is very limited hence could not get the desired output.