I am having the table named tbl_sales and this table contains the fields active and is_featured. Now i am trying to get the count of the records where active=0, active=1, is_featured=1 and is_featured=0. How can i get this in a single query. Can somebody show me a query to get this. I am a newbie to programming and in a self learning process. Need solutions. Thanks in advance
I am having the table named tbl_sales and this table contains the fields active
Share
Try using
SUM:The
IF(active=0,1,0)says “if active is 1, return a 1. otherwise, return a 0”.The
SUMaround it adds up all the numbers, which are 0 if non-active and 1 if active (etc).