1
I have a following table:
tbl_mission
- id_misssao
- assignment
- status
- id_warrior
- id_creator
When the user creates a mission, he can add this mission to himself or he can indicate another user (warrior) to accomplish this mission. The logic is as follows:
- When creating a mission without indicating a warrior, creates a mission record for the user himself who is registering leaving the field
id_guerreiro = NULL
. - When creating a mission indicating the warrior, create a record in the table containing the identifier of the warrior and the author of the mission.
Problem
I would like to create a query that shows the total number of missions a user has, but it is necessary to create a condition to verify that the id_guerreiro
is void or not.
IF id_warrior equals NULL,
THEN returns a counter by checking the amount of items that exists for the id_criador_da_missao
OTHERWISE return a counter by checking the total amount of items in the id_guerreiro
.
The following query calculates the total number of items, but only by checking the id_criador_da_missao
. There is a way to check the two columns and return the total?
SELECT COUNT (id_criador_da_missao ) TOTAL FROM TBL_MISSAO
You want to return all in the same counter or you want to return an accountant to missions that belong to this creator and missions of which he is the warrior?
– Sorack
@Sorack I want to return the total amount of missions that a warrior has, but when there is no warrior in the item, you have to check the identifier of the creator of the mission that would be the mission director himself.
– viana
Okay, so the answer I put in will do for you
– Sorack