var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: shows the id that have 3 records and fewer than 2 NO
I have some records in a table 'Preference'
I would like to return the id that have 3 records but less than 2 'N' in the 'Access' column (sample table below)
It is suppose to return
I tried a query below but it doesn't return any record
Any idea where I did wrong? Thanks
select distinct ID from Preference where ID in (select distinct ID from Preference group by ID having count(Access)=3) and Access = 'N' group by Access having count(*) < 2
HAVING COUNT(*) = 3
AND COUNT(CASE WHEN Access = 'N'
ELSE NULL END) < 2