I have a table with following columns,(id,fkid, flag1,flag2,flag3,flag4). The possible value for each flag field is -1 to 3 and null is allowed. What I need is a query to check if count of any flag field with value 2 is greater than 3 for a given foreign key fkid. The way I am doing is write a query for each field. It works but very not smart to me. Anyone has better idea? Thanks.
I have a table with following columns,(id,fkid, flag1,flag2,flag3,flag4). The possible value for each flag
Share
You can do this with one query:
I do agree strongly with the comments, though, that sample data, sample results, and a clear table structure would greatly improve the question.