Is it possible to form a query that will add the results of these 2 queries together?
SELECT "output1" FROM "output1"
SELECT "output2" FROM "output2"
It is to display a Singlestat value in Grafana.
Thanks
Unfortunately there isn't a way to join data across two measurements.
As a work around you could use a continuos query to write data into the same measurement like so
CREATE CONTINUOUS QUERY join_output1_output2 ON mydb BEGIN
SELECT "output2" INTO "output1" FROM "output2"
END
Then the query
SELECT "output1" + "output2" FROM "output1"
Related
I want to query the database but only find out if there is at least one result or not. I am trying to minimize the cost for this transaction. What would the structure be in Rails to have the query be SELECT TOP or SELECT FIRST in SQL?
You could try exists?
Person.exists?(5) # by primary key
Person.exists?(name: 'David')
Person.exists? # is there at least one row in the table?
Person.where(name: 'Spartacus', rating: 4).exists?
Person.active.exists? # if you have an "active" scope
Note that this limits the result set to 1 in the SQL query and the select clause is something like SELECT 1 AS one
When I run a distinct query on the influxdb, I get all results within one row. I need them all on different rows.
I've tried to select other fields however with distinct you can only select one field to query.
SELECT distinct("value_name") FROM "value_data"
name: value_data
time distinct
0 [TT_2028 TT_2090 TT_2216 TT_2217 TT_2237 TT_2238 TT_2239 TT_2240 TT_2241 TT_2243 TT_2248 TT_2249 TT_2250 TT_2251 TT_2252 TT_2253 james_test master testing_nightly_build test2]
I need the distinct values in new rows, not all on one row.
The docs show a distinct query with serrated rows
https://docs.influxdata.com/influxdb/v1.7/query_language/functions/#distinct
I think that you search for group by instead of distinct on string field.
Try something like this:
SELECT data1 FROM "value_data" GROUPBY value_name
I'm trying to create a continuous query in InfluxDb to downsample the measurement data to the hourly mean values. I can do that with the continuous query below.
CREATE CONTINUOUS QUERY "cq_test_1h" ON "db-name"
BEGIN
SELECT mean("value") AS "mean_value"
INTO "downsampled"."downsampled_measurement"
FROM "autogen"."measurement"
GROUP BY time(1h)
END
But I also want that if the hourly mean equals zero, the result is excluded; so the downsampled_measurement series does not contain any zero values. I can make a (nested) query that does what I want, but I don't know how to make this into a continuous query.
SELECT mean_value
FROM
(SELECT mean(value) AS mean_value
FROM "measurement"
WHERE time<now()
GROUP BY time(1h))
WHERE mean_value>0
The query above works, but to make it a continuous query it needs an aggregator, GROUP BY clause and a duration argument in the WHERE clause:
SELECT mean(mean_value)
FROM
(SELECT mean(value) AS mean_value FROM "db-name"."autogen"."measurement"
WHERE time<now()
GROUP BY time(1h))
WHERE mean_value>0 AND time<now()
GROUP BY time(1h)
However, this query no longer returns any values. How can I make a continuous query that excludes zeros?
I am writing a hive query to join two tables; table1 and table2. In the result I just need all columns from table1 and no columns from table2.
I know the solution where I can select all the columns manually by specifying table1.column1, table1.column2.. and so on in the select statement. But I have about 22 columns in table 1. Also, I have to do the same for multiple other tables ans its painful process.
I tried using "SELECT table1.*", but I get a parse exception.
Is there a better way to do it?
Hive 0.13 onwards the following query syntax works:
SELECT a.* FROM a JOIN b ON (a.id = b.id)
This query will select all columns from a. So instead of typing all the column names (making the query cumbersome), it is a better idea to use tablealias.*
I want to query data from multiple models and group it and order it.
How do i do it with Realm?
In the SQLite / MySQL, i can use UNION to combine the queries and GROUP BY to group common field's value.
Im switching to Realm and now i'm stucking in how to perform it.
Here is an example about the query in SQLite
SELECT w1,abc('\(word)', kd) as lscore,freq FROM ng1 WHERE kd LIKE '\(beginchar)%\(lastchar)'
UNION
SELECT w2,abc('\(word)', kd) as lscore,freq FROM ng2 WHERE w1='\(lastword)' AND kd LIKE '\(beginchar)%\(lastchar)' ORDER BY lscore ASC,tp DESC,freq DESC LIMIT 0,4
Realm doesn't currently support UNION's