I have a following table:
tbl_missao
- id_misssao
- hostname
- status
- war_id
- commit_server_id
When you create a mission, it can add that mission to itself or you can tell another user (warrior) to perform this mission. The logic is as follows:
- When creating a mission without indicating a warrior, it creates a mission record for the user to be registering leaving the
id_guerreiro = NULL
field. - When creating a mission indicating the warrior, create a record in the table containing the warrior's identifier and the mission's author.
Problem
I would like to create a query that shows the total number of quests a user has, but you must create a condition to check whether id_guerreiro
is null or not.
SE war_id is equal to NULL, then THEN return a counter checking the quantity of items that exist for id_criador_da_missao
SENÃO return a counter checking the total amount of items of id_guerreiro
.
The following query calculates the total of items, but only by checking the id_criador_da_missao
column. Is there a way to check the two columns and return the total?
SELECT COUNT (id_criador_da_missao ) TOTAL FROM TBL_MISSAO