How to count the number of records with specified condition on fields in SingleStat panel

I have some data that like:

> select * from log where time < now() - 2h and value1<100
name: log
 ---------
 time				name	value1	value2	value3 
 2018-04-09T01:17:55.350626995Z	h1	75	120	80
 2018-04-09T01:18:37.58407287Z	h1	80	94	89
 2018-04-13T03:39:38.22804839Z	h1	78	200	200

Here the log is measurement. value1, value2 and value3 are fields. The value for the tag name can be h1, h2, and so on.

I want to count the number of unique names, the value1 of which are less than 100.

How can I configured it on grafana? In the metrics tab, only the tag(name) is allowed to be added here.

Thanks for your help.