Try something like this:
<pre>SELECT “T16.CPRP”.CP_DISTRICT_CODE,
CASE “T16.CPRP”.CP_DISTRICT_CODE
WHEN ‘xx’ THEN SUM(“T16.CMCL”.MC_TAX_AMOUNT) AS TOWN
WHEN ‘yy’ THEN SUM(“T16.CMCL”.MC_TAX_AMOUNT) AS TOWN
ELSE SUM(“T16.CMCL”.MC_TAX_AMOUNT/2) AS TOWN
END,
SUM(“T16.CMCL”.MC_TAX_AMOUNT/2) AS COUNTY</pre>
(Replace ‘xx’ and ‘yy’ with the special district-codes which shall not be divided. And let the rest of your code remain.
Happy coding
—————————————
It could be done in different ways depending on the database.
One option could be the use of a CASE expression.
Something like this (in this example, 1 and 2 are the codes that don’t need the MC_Tax_Amount divided by 2) :
<pre>SELECT “T16.CPRP”.CP_DISTRICT_CODE,
SUM(“T16.CMCL”.MC_TAX_AMOUNT/CASE “T16.CPRP”.CP_DISTRICT_CODE
WHEN 1 THEN 1
WHEN 2 THEN 1
ELSE 2 END) AS TOWN ,
…
…</pre>
In oracle, the DECODE function would simplify this.
-CarlosDL
—————————————-
Discuss This Question: 7  Replies