I have pretty simple measurement in influxDB and have default time column and two other columns as shown below,
Select * from measurement
gives me this out put.
time component_id jkey
2016-09-27T02:49:17.837587671Z 3 "timestamp"
2016-09-27T02:49:17.849447239Z 3 "init_time"
2016-09-27T02:49:17.885999439Z 3 "ae_name"
2016-09-27T02:49:17.893056849Z 3 "init_time"
How can i select the last record of this measurement? The record which have maximum time value.
This can be done with last(). See the docs for more information: link. Or take a look at this example from the docs.
SELECT LAST("water_level") FROM "h2o_feet" WHERE "location" = 'santa_monica'
This will return the "newest" entry.
Related
I have 2 tables, in one there are transactions in USD, in the other there are monthly USD<>CHF exchange rates.
I want to automate the picking of the correct exchange rate for a given date.
tables
The formula would be inserted into 'Table 1 - Exch. Rate' column.
It should check what date it is ('Table 1 - Date') and then check which 'USD<>CHF' matches the date in Table 2.
For example, for Jan 30th it would insert 0.93061.
I played around with 'Query' but can't make it work. Is this the way to do it or is ther a better function?
you could go with a simple vlookup or xlookup function.
=index(if(len(A2:A),xlookup(A2:A,F:F,G:G,),))
Ok so the need - I have about 3700 lines of email addresses, names, schools, and professions(those are column headers) I want to split this sheet into 4 with 1000 lines(I understand one will be short) in each but here is the catch I can only have 25 lines/emails from each school. So how would someone go about doing this? Keep in mind each sheet needs to have its own unique emails not repeated on the other sheets.
There are 2 problems here and as I don't know how many schools are on the list and if it's possible to have always less than 25 people from one school (for example - if there are only 30 schools, it would be impossible to distribute them in 1000 row batches).
First task:
Distribute database into 4 sheets, 1000 rows each:
It's simple.
Let's say my data has 4 columns from A to D
I make sheets named 1-1000, 1001-2000, etc.
In each one I put a formula:
1)
=query(Master!A1:D,"select * limit 1000 offset 0")
=query(Master!A1:D,"select * limit 1000 offset 1000")
=query(Master!A1:D,"select * limit 1000 offset 2000")
=query(Master!A1:D,"select * limit 1000 offset 3000")
Etc.
In order to limit number of occurences of each schools, I have to count these occurences and define what is the minimal page number on which this student can be displayed (for example - 17th student from certain school can be on 1st page, but 27th can be at least on 2nd page. 60th student can be on third or further.
When I determine minimal page number, I can sort my data accordingly and display sorted by minimal number:
In this situation my query on next pages have additional parameters:
=query(Master!A1:G,"select A,B,C,D order by G limit 1000 offset 0")
I use column G for sorting, but I don't display it.
You can find my solution here:
https://docs.google.com/spreadsheets/d/1TP6MlMmLiUExOELFhgZnti7LR7VQouMg3h-X7QRcHzQ/copy
Names are generated randomly from polish names generator.
I am new to influx db, please help me with query?
I have below like data in influx where same Name data (A1, A2) can be available for multiple time.
I need only latest time stamp data (row 3,4,5) if same data is available in multiple time stamp and the new data (A3). Is such query available in influx?
this query only gives one record,
SELECT time, Name, value FROM "data" order by time desc limit 1
You can use the InfluxDB's last function to achieve this.
SELECT LAST("value") FROM AssetAssetType GROUP BY "Name"
I Have 4 columns I am interested in creating a list. We collected weekly data from our third party vendor. We sort it by the DataCollection week. They do not always submit this data. So, there will be times where a Vender submitted one week but not the next. I need to have a running total of total enrollments by the collection week broken down by the name. I did the MAX function but that only gives me the latest date in the whole table, I want the max for each districts individual date. How do I accomplish this so that say, if the latest week is 2/21/2020 for Name A, and the latest week for Name b was 2/14/2020, I can have both dates and enrollment totals, because as it stands I get only the max date which is 2/21/2020 but the names of those other districts that submitted the data are not coming back.
The code below is what I have.
SELECT DATACOLLECTIONWEEK, NAME,DISTSCH,TOTALENROLLMENTS
FROM DB.SCHEMA.TEST
WHERE datacollectionweek = (SELECT MAX(datacollectionweek)
FROM DB.SCHEMA.TEST)
SELECT DATACOLLECTIONWEEK, NAME,DISTSCH,TOTALENROLLMENTS
FROM DB.SCHEMA.TEST as DB1
WHERE DB1.datacollectionweek = (SELECT MAX(datacollectionweek)
FROM DB.SCHEMA.TEST AS DB2
WHERE DB1.NAME = DB2.NAME)
I need to come up with a form in SSRS 2008 that prints labels based on information stored in a table or tables. So far I have been unsuccessful in my online searching. How do I tell SSRS that I want the KitOrder.QuantityCommitted quantity of labels to print for each item? (each item has it's own quantity) I will likely be printing labels for 20-30 items at a time. In case it's helpful to know, there are 18 blank labels per sheet.
edited 10/01/15
Sorry, I played around with with the example you gave and wasn't able to get my report to work. I am not an expert with SSRS.
I have 2 tables I am using to get the info I need for the labels and only need the columns listed below the table names at this point.
KitOrder INNER JOIN Item
KitOrderNumber ItemNumber
Quantity ItemDescription
I am using KitOrderNumber from a dropdown box - IN(#KitOrderNumber) - as my Parameter. The ItemNumber and ItemDescription print on the label. Would there be some custom code I could use that would return 3 labels when KitOrder.Quantity = 3 instead of just 1 label?
Edited 10/05/15 - I was finally able to get my report to work as needed. Thanks so much for your help. The sqlfiddle was quite helpful to me.
I hate when people suggest this when it's not necessary but I think this is one of the times that you'll need to manipulate your data in SQL before the report.
I can't think of an easy way to do it with SSRS that doesn't involve a lot of code.
You create a temp table with your possible quantities then cross join your table to create a separate record for each product based on the number in your Quantity field.
;WITH Quantities AS (
SELECT 1 AS Num
UNION ALL
SELECT 1 + Num
FROM Quantities
WHERE Num <= 30
)
Select * from Products
CROSS JOIN Quantities
WHERE Num <= Quantity
This assumes that your data is in a table called Products.
If you have a query, you can SELECT your fields INTO a #Temp table and use that in the Select statement.
For the report, you can set the Columns peoperty on the Report to use as many columns as your label sheet has.
Here's an SQLFiddle I made that you can play with:
http://www.sqlfiddle.com/#!3/bb413/2