-1

we have 2 table, table A and table B,

we are fetch 6 columns in select statement, these are the columns

  1. A.current_value,
  2. A.original_value,
  3. A.current_tax_lot,
  4. B.current_tax,
  5. B.cost_tax,
  6. B.current_tax_cost

now we have to put mathematics condition in query:

  1. A.current_value – B.current_tax is within +/- 2, and

  2. If A.original_value is blank use A.current_tax_lot to perform the formula:

2a. A.current_tax_lot (from above) – B.cost_tax is within +/- 10, or

2b. A.current_tax_lot(from above) – current_tax_cost is within +/-10)

jarlh
  • 42,561
  • 8
  • 45
  • 63
  • 1
    Homework, nice! If you run into a specific problem you can ask a question here. But don't forget to add sample table data, the expected result and your code attempt. (All as properly formatted text, no images.) – jarlh Nov 06 '20 at 08:18
  • BTW, are you using MS SQL Server or Oracle? – jarlh Nov 06 '20 at 08:19
  • 1
    should do homework by yourself though, anyway this seem like a question that can easily solve by using `case` just like your topic said... – T. Peter Nov 06 '20 at 08:22
  • @jarlh its oracle – Tulsi Thakur Nov 06 '20 at 08:42
  • @Craig query looks good but why are we not using (point b) If A.original_value is blank use A.current_tax_lot – Tulsi Thakur Nov 06 '20 at 08:44

1 Answers1

0

If have not understood a block/calculation, substitute terms / expressions appropriately.

Select  ...
Where 
      ABS(NVL(A.current_value, A.current_tax_lot) – B.current_tax) <=2
      AND 
      (
         ABS(A.current_tax_lot – B.cost_tax) <= 10 
         OR
         ABS(A.current_tax_lot – B.current_tax_cost) <= 10
      );
Craig Gers
  • 544
  • 3
  • 9