I have the following sql query:
SELECT field_number, COUNT(*) AS c FROM lead_detail WHERE field_number < 3 AND field_number > 2 AND lead_id IN (147,146,145,127,113) GROUP BY field_number
It returns:
field_number c
2.1 5
2.2 5
2.3 1
2.4 1
2.5 5
I only want to display some fields according to user selection so i used:
SELECT field_number, COUNT(*) AS c FROM lead_detail WHERE field_number < 3 AND field_number > 2 AND lead_id IN (147,146,145,127,113,109,91,65,57,56,49) AND field_number IN (2.1,2.3) GROUP BY field_number
But now with this query im getting 0 results. I tried to put AND field_number = 2.1 without success.
Any clue why this is happening or how i can avoid this?
lead_id id`s dont have all field_numbers , i think this maybe is the reason. For example in lead_id 147 we can find field_numbers 2.1 and 2.3 and in lead_id 146 we find 2.4 and 2.5
Thanks for the great help
Yo have a typo error in your query it suppose to be
COUNT(*) AS calso you have two unnecessary statements there use
field_number < 3 AND field_number > 2orfield_number IN (2.1,2.3)so final query should look like this: