Below is the query that i am using. but
Query:
SELECT c.session_id session_number,
u.first_name first_name,
u.last_name last_name,
Min(c.timestamp) session_start_ts,
Max(c.timestamp) session_end_ts,
Count(
CASE
WHEN c.message_type='IN' THEN 1
ELSE NULL
END) message_in_count,
Count(c.message_type) total_messages
FROM users u
join chatlog c
ON u.user_id = c.user_id
WHERE Trunc(c.timestamp) BETWEEN To_date('2017-10-11','YYYY-MM-DD') AND To_date('2017-11-09','YYYY-MM-DD')
GROUP BY c.session_id,
order by timestamp;
The problem is that it gives an error stating "not a GROUP BY expression". But instead of just grouping by session id if i use :
group by c.session_id, u.first_name, u.last_name, c.timestamp
It works though the values of first_name and last_name are same for a particulat session_id and timestamp also i am only taking the max. so cant understand why i am unable to group by session_id only.