Answer the question
In order to leave comments, you need to log in
How to compose a MSSQL query?
Greetings.
You must choose to create a query that will count the number of dates by the range of dates + group it. If nothing was found in the range for some date, you need to display it and set it to 0.
Here's what I got:
SELECT COUNT(DISTINCT(session_id)) AS count1,
CONVERT(varchar(10),event_time,120) AS event_time
FROM dbo.logs_ft
WHERE CONVERT(varchar(10),event_time,120) BETWEEN '2017-11-01'
AND '2017-11-09'
AND event = 'recognition_result_interpretation'
AND value = '1'
GROUP BY CONVERT(varchar(10),event_time,120)
Answer the question
In order to leave comments, you need to log in
Miracles, Cinderella, do not happen. If this is a selection, then you can only select something that exists in the database. If the record does not exist, then you can do CASE sessionid is null then 0 else sessionid end
case write instead of Null - 0, it's real.
But if there is no date, then it is unrealistic to magically put the correct date value instead of Null.
Means? You will have to do this date by hand. You make a variable. Throw in it the minimum value of the range, 01. Then make this variable DateAdd + 1 day, if the number of records is strictly equal to the range.
If not, then fill in the temporary table. Cursor/loop. The number of days is. You give it some id and put the same id in any way in your first request. Further join between them. Everything.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question