I have table like this
I just want to get all userIds and bookId which have just one bookId. I am using the following query
SELECT userId, count(DISTINCT bookid) AS num_books FROM table GROUP BY userId HAVING num_books=1 I also need to then join with some other tables. This query is excruciatingly slow. I am sure there is a better way to write this query, I just cant figure out the way...
