SQL - Query on a single table with null values

1

Hello,

I need to do a filtered query by date. The problem is that dates that do not exist in the table need to be returned by the query, having all other fields as Nulls.

SELECT Data, Servico
FROM controle_equipe
WHERE ((Data >= #4/1/2016#) And (Data <= #5/2/2016#));

The big jump is to return all the dates of the selection criteria, even though they are not contained in the team_control table. I've tried using IIF, CASE, but without success

    
asked by anonymous 03.05.2016 / 01:59

3 answers

2

See if it works for you:

SELECT Data, Servico
FROM controle_equipe
WHERE ((Data >= #4/1/2016#) And (Data <= #5/2/2016#)) OR Data Is Null;
    
03.05.2016 / 05:33
0

I'm used to MS-SQL but see if this syntax exists and can be applied:

 SELECT Data, Servico FROM controle_equipe
 WHERE (Data >= '4/1/2016') And (Data <= '5/2/2016'))
 AND IsNull(Data,1) <> 1
    
03.05.2016 / 17:24
0

So I understand you need to have another table with all the TCALENDARIO dates, then just in the where clause, put controle_equipe.data = TCALENDARIO.data (+)

    
05.06.2018 / 07:05