Sql: Can Where Statement Filter Out Specific Groups For Group By Statement
I'm still new to SQL and playing inside a SQLite3 test database. I tried digging online for this answer but could not find an answer. I cannot get my test query to exclude certai
Solution 1:
>SELECT0<>0;
0>SELECT'0'<>0;
1
You have string values in your database. Fix them:
UPDATE MyTable
SET Session_ID =CAST(Session_ID ASINTEGER);
Solution 2:
Your methods works for me (as expected) with a simple dataset.
createtable tbl (user_id int, session_id int, duration int);
insertinto tbl values (1,0,10);
insertinto tbl values (1,1,2);
insertinto tbl values (2,1,1);
insertinto tbl values (3,2,1);
insertinto tbl values (4,2,5);
SELECT USER_ID, SESSION_ID, MAX(duration), count(1)
FROM tbl
WHERE SESSION_ID <>0GROUPBY USER_ID, SESSION_ID
Post a Comment for "Sql: Can Where Statement Filter Out Specific Groups For Group By Statement"