Question: If I have many classes which are pretty similar with each other then, does making them inherit from an abstract class a good option?

Answer: 
You can do that calculation all in one go if all you want is a total of the debits and credits

```
SELECT 
    SUM(CASE WHEN DebitCredit='H' THEN AmountLC*-1 ELSE AmountLC END) as Total
FROM T1_CSV_Table 
WHERE Month='$getMonth' AND TaxCode='A0'

```

> 
> NOTE: Your script is at risk of [SQL Injection Attack](https://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php)
>  Have a look at what happened to [Little Bobby Tables](http://bobby-tables.com/) Even
>  [if you are escaping inputs, its not safe!](https://stackoverflow.com/questions/5741187/sql-injection-that-gets-around-mysql-real-escape-string)
>  Use [prepared parameterized statements](http://php.net/manual/en/mysqli.quickstart.prepared-statements.php)
> 
> 
>
try this please:

```
SELECT
    SUM(IF(DebitCredit='H', DebitCredit, 0) AS NegativeTotal,
    SUM(IF(DebitCredit='S', DebitCredit, 0) AS PostiveTotal
FROM T1_CSV_Table 
WHERE
    MONTH='$getMonth'
AND
    TaxCode='A0';

```