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.

  • 1
    Have a look at COUNT – McNets Oct 5 '19 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 '19 at 17:18
  • request, to receive simple code example – Sjaakarie Oct 5 '19 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 '19 at 23:03

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