MySQL INNER JOIN giving no data

Using MySQL data source and following query containing INNER JOIN to get time series data. But it is giving Data is missing a number field error.

SELECT
  $__timeGroupAlias(up.created,$__interval),
  count(id) AS "Total"
FROM plans_userplan up
INNER JOIN plans_planquota pq ON pq.plan_id = up.plan_id
INNER JOIN plans_quota q ON q.id = pq.quota_id
INNER JOIN authentication_user u ON u.id = up.user_id
WHERE
  $__timeFilter(up.created) AND q.codename = 'CUSTOM_SCRIPT' 
GROUP BY 1

But data is available in the database and can be retrieved using (modified query)

select
  count(*)
from plans_userplan up
inner join plans_planquota pq on pq.plan_id = up.plan_id
inner join plans_quota q on q.id = pq.quota_id
INNER JOIN authentication_user u on u.id = up.user_id
where q.codename = 'CUSTOM_SCRIPT' 

Remove the following from the WHERE filter in grafana and see what happens

$__timeFilter(up.created)

@yosiasz Same error after removing $__timeFilter(up.created)

Oh sorry, can you use transformation and convert ghat Total field to Number?

Tried using the Convert field type transformation. but there is no option to select

Got it resolved by putting count(*). It seems the issue was due to the ambiguity of the id field in the count() function.

1 Like