0

I have this query:

WITH COST (
SELECT 
PRICE 
,OTHERCOLUMN
FROM TABLECOST)
SELECT 
COL_1
,COL_2
,OTHERCOLUMN AS QUANTITY
,CASE 
     WHEN PRICE = IS NULL THEN COL_3
     ELSE PRICE END AS UNIT_COST
,UNIT_COST * QUANTITY AS TOTALCOST
FROM TABLE_FINAL

And it is said that the column 'UNIT_COST', which one was created in a case sentence before does not exist, how can i fixed that?

a_horse_with_no_name
  • 497,550
  • 91
  • 775
  • 843
margo1395
  • 3
  • 1
  • `UNIT_COST` is an alias for your case expression, and it does not exist as a column inside the same query. I also fail to see the usage of the CTE in the outer query. Could you please elaborate on that? – Jim Jones Nov 03 '21 at 13:13

0 Answers0