FROM batt_State s INNER JOIN pnLU p ON s.PartNo = p.PartNo WHERE battState IN ('1','20','30','31','99') GROUP BY s.partNo, p.descript

Oh sure...that will only be better if you want the query to be faster.

That's also assuming that the business requirement is to return rows only where battState IN ('1','20','30','31','99'), which isn't stated by the OP. If he wants a row for every partNo in the batt_State table, but only wants the aggregate SUM values where battState IN ('1','20','30','31','99') (leaving 0 in these columns for other values of battState), then the WHERE battState IN ('1','20','30','31','99') clause should be omitted.

FROM batt_State s INNER JOIN pnLU p ON s.PartNo = p.PartNo WHERE battState IN ('1','20','30','31','99') GROUP BY s.partNo, p.descript

Oh sure...that will only be better if you want the query to be faster.

That's also assuming that the business requirement is to return rows only where battState IN ('1','20','30','31','99'), which isn't stated by the OP. If he wants a row for every partNo in the batt_State table, but only wants the aggregate SUM values where battState IN ('1','20','30','31','99') (leaving 0 in these columns for other values of battState), then the WHERE battState IN ('1','20','30','31','99') clause should be omitted.

You're absolutely right, Wolfie - but as an experienced dev, I'd bet that you'd write the same as I did, or possibly both, and offer it to a stakeholder to choose.

FROM batt_State s INNER JOIN pnLU p ON s.PartNo = p.PartNo WHERE battState IN ('1','20','30','31','99') GROUP BY s.partNo, p.descript

Oh sure...that will only be better if you want the query to be faster.

That's also assuming that the business requirement is to return rows only where battState IN ('1','20','30','31','99'), which isn't stated by the OP. If he wants a row for every partNo in the batt_State table, but only wants the aggregate SUM values where battState IN ('1','20','30','31','99') (leaving 0 in these columns for other values of battState), then the WHERE battState IN ('1','20','30','31','99') clause should be omitted.

You're absolutely right, Wolfie - but as an experienced dev, I'd bet that you'd write the same as I did, or possibly both, and offer it to a stakeholder to choose.

For something this short, I probably would just write it and show the stakeholder the results with and without the WHERE clause. Anything more complex, I'd want clarification of the requirements first - I don't like to spend too much time coding after phantom requirements.