I would like to perform a query on the FILE_EXAME table with the following data:
CREATETABLEFICHA_EXAME(FICHAsmallint,EXAMEVARCHAR(15));INSERTINTOFICHA_EXAMEVALUES(1,'Hemograma');INSERTINTOFICHA_EXAMEVALUES(1,'Colesterol');INSERTINTOFICHA_EXAMEVALUES(1,'Ferro');INSERTINTOFICHA_EXAMEVALUES(2,'Colesterol');INSERTINTOFICHA_EXAMEVALUES(3,'Ferro');INSERTINTOFICHA_EXAMEVALUES(3,'Hemograma');INSERTINTOFICHA_EXAMEVALUES(4,'Ferro');
InthequerythatIcreated,Iwouldliketoseewhichexamsarecontainedintheextractedsheetthrougha" Has or does not have ", and do not list the exam in fact, but would like it to appear in only 1 line.
I tried the form below, but for each exam related to the card, it brings me a new line, and I would like it to be displayed dynamically on a single line, regardless of whether there was more than one exam on the same card:
SELECT FICHA,
CASE WHEN EXAME = 'Hemograma' THEN 'S' ELSE 'N' END AS 'POSSUI HEMOGRAMA?',
CASE WHEN EXAME = 'Colesterol' THEN 'S' ELSE 'N' END AS 'POSSUI COLESTEROL?',
CASE WHEN EXAME = 'Ferro' THEN 'S' ELSE 'N 'END AS 'POSSUI FERRO?'
FROM FICHA_EXAME;
Result :