You can help me with the following, I currently have a query from a table sql-server which brings me the records depending on a condition in WHERE
and classifies those records into 4 categories which are' Contrato
',' Otrosies
',' Garantias
'and' Polizas
'. This is done through the function CASE
, the name of the category the store in an extra column which the function CASE
gives me the possibility to create, this column will assign the name " CLASIFICACION
",
The records are classified successfully in the categories mentioned above but the problem I have is that I need my query to only bring me the records that are within these 4 categories, since when finding records that do not meet these conditions in the CASE
, in my extra column " CLASIFICACION
" assigns them the value NULL
and also brings me those records.
Here my query:
SELECT
TituloDocumento, TipoDocumentoAcuerdo,
Contenido,
CLASIFICACION=
CASE
WHEN
TipoDocumentoAcuerdo IN ('CONTRATO','CONTRATO E&P', 'CONTRATOS CON SOCIOS') THEN 'CONTRATO'
WHEN
TipoDocumentoAcuerdo = ('OTROSIES') THEN 'OTROSIES'
WHEN
TipoDocumentoAcuerdo = ('GARANTÍAS') THEN 'GARANTÍAS'
WHEN
TipoDocumentoAcuerdo = ('GARANTÍAS') AND TituloDocumento LIKE ('%POLIZA%') THEN 'POLIZAS'
END
FROM reporte_documentos_Tecnicos
WHERE Contenido = ('Acuerdos de Gobierno')
Thank you very much for your help.