Hi there was wondering if someone could help me out, and can give me a little code example. i have a table named "projecten", and columns named "pstatus and pafgifte" these columns have numbers only. I would like to count up all "pafgifte" with "pstatus = 2" only, and echo result.

help would be appreciated.

closed as off-topic by mustaccio, MDCCL, Vérace, Michael Green, Laurenz Albe Oct 7 at 6:29

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Too localized - this could be because your code has a typo, basic error, or is not relevant to most of our audience. Consider revising your question so that it appeals to a broader audience. As it stands, the question is unlikely to help other users (regarding typo questions, see this meta question for background)." – mustaccio, MDCCL, Vérace, Michael Green, Laurenz Albe
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    Have a look at COUNT – McNets Oct 5 at 15:18
  • In addition to COUNT, you will need to GROUP BY your fields. If you're still having problems, get back to us - I realise that not everybody was born knowing SQL! p.s. welcome to the forum! :-) – Vérace Oct 5 at 17:18
  • request, to receive simple code example – Sjaakarie Oct 5 at 20:05

Like this:

select sum(case when pstatus=2 then pafgifte else 0 end) pafgifte_total
from projecten

Assuming you mean to add the numbers together.

  • thank you for your example – Sjaakarie Oct 5 at 23:03

Not the answer you're looking for? Browse other questions tagged or ask your own question.