Conditional Count on a field

前端 未结 8 1807
庸人自扰
庸人自扰 2020-11-28 06:55

If I had a table like this:

jobId, jobName, Priority

Whereby Priority can be an integer between 1 to 5.

Since I would need this que

8条回答
  •  攒了一身酷
    2020-11-28 07:26

    I would need to display the jobid, jobname and 5 fields called Priority1, Priority2, Priority3, Priority4. Priority5.

    Something's wrong with your query design. You're showing a specific job in each row as well, and so you'll either have a situation where ever row has four priority columns with a '0' and one priority column with a '1' (the priority for that job) or you'll end up repeating the count for all priorities on every row.

    What do you really want to show here?

提交回复
热议问题