Skip to main content
Code Review

Return to Revisions

2 of 9
title was not ok

Calculating price with a sub querry

Here is my request :

Select a, b, c, d,
 price *(select p.value1 From Params as p where p.PAR_Field = 'Taxe' and p.PAR_KEY = 'TVA')/100 as RealTVA,
 price+price*(select p.value1 From Params as p where p.PAR_Field = 'Taxe' and p.PAR_KEY = 'TVA')/100 as RealPuTTc,
 Qte*(price+price*(select p.value1 From Params as p where p.PAR_Field = 'Taxe' and p.PAR_KEY = 'TVA')/100 As RealPtTTC,
 price*(select p.value1 From Params as p where p.PAR_Field = 'Taxe' and p.PAR_KEY = 'TVA')/100 as RealTVA
 
From myTable
 left outer join myTable2
 on mt_Key = Mt2_mt_key

I Want to get the Sub query out to make the code sexier. I was planning to use a CTE but now i dont see how. If you have any idea, please tell me.

lang-sql

AltStyle によって変換されたページ (->オリジナル) /