select - Access query distinct record when all rows same -
not sure how phrase question/description, ask example.
in access, need run query return 1 record, if rows of (2 column) select distinct same.
so:
style | flag
123 | y
123 | n
123 | y
456 | y
456 | y
456 | y
789 | n
789 | n
789 | n
i want return 456 once because versions of '456' style have flag = 'y'. style '123' not returned because it's mixed 'y' , 'n'. style '789' should not returned because instances 'n'. trying return "all 'y', 'y' records"
split query 3 parts
part 1, group style , flag (count rows information) save query1
select table1.style, table1.flag, count(table1.id) countofid table1 group table1.style, table1.flag;
part 2 - group style, , count number of flag records, filter show records flag count of 1. save query2
select query1.style, count(query1.flag) countofflag query1 group query1.style having (((count(query1.flag))=1));
part 3 - join original table, , filter show styles y flag.
select table1.style, table1.flag query2 inner join table1 on query2.style = table1.style group table1.style, table1.flag having (((table1.flag)="y"));
(table1, query1, query2, query3 names can replaced more meaningful problem set).
Comments
Post a Comment