I have the following query:
SELECT COUNT(co.sexo_id) as TOTALDIA, se.SEXO FROM CONDUCTORES co JOIN TRAMITE tr ON co.conductor_id=tr.conductor_id join LICENCIAS lic on tr.licencia_id=lic.licencia_id join CAT_SEXO se on se.SEXO_ID=co.sexo_id WHERE YEAR(fecha_captura) = YEAR(GETDATE()) AND MONTH(fecha_captura) = MONTH(GETDATE()) GROUP BY se.SEXO ORDER BY TOTALDIA ASC, SEXO asc
This brings me this:
I would like to get something like this:
Annex the following Data For the suggestion that makes me @Mauricio Arias Olave
My table CAT_SEXO gives me the Type of SEX and is related to CONDUCTORS through the field sex_id which is a field of binaries if it is 1 = FEMALE if it is 0 = MALE the table CONDUCTORS is related to the table TRAMITES that only serves me for Relationship with LICENSES from which I obtain the Date. and the counting I do based on the field sex_id of the CONDUCTORES Table.
Those are the Data of My tables I also hope that explains why I use all the tables. The query it brings is correct, but what I'm looking for is that the data from the SEXO Pertaining Field are in Different Fields @gbianchi, I was testing with LIKE and similar but I do not get it, that's why I resort to this Master zone, I think it should be a comparison based on the SEX_ID field of my CAT_SEXO table which is a fixed table from there I take the data.