I have a weather station where I measure the amount of rain per hour and save the data in a database. The rain-table looks like this: Now I want the longest rainless time per month. I already have a solution, but it only works for the respective day. However, if there is no rain for several days, my solution will
Tag: date
Add additional column to the query output
I have the following query that is grabbing data from a table and combining all the products into one column and counting the quantity of that order. I need to add an additional column to the output though, how can I also add ship_date? This is how the original table is laid out: And this is how the query outputs
display all the 1year back from current data in the table in db2
this is my table. i want to extract records of last 1 year from current date. so my output should be Answer In the WHERE clause set the condition that dob is greater than the current date minus 1 year: If you want all the rows of the current and the previous year: See the demo.
How to successfully convert string to date type in AWS Athena?
I’m trying to convert a date column of string type to date type. I use the below query in AWS Athena: SELECT a, b, date_parse(date_start, ‘%m-%d-%Y’) AS date_start FROM “database”.”…
SQL Select – Get a count of data as a separate column error
I am working on this query whereas I have a table as follows Code | Date ————- 001 | 20-JUN 001 | 20-JUN 002 | 20-JUN 003 | 20-JUN 002 | 20-JUN 001 | 20-JUN 002 | …
Split multi-month records into individual months
I have data in a table in this format – where date range is multi-month: I want to create a view/ insert into a new table – the above record broken by month as shown below: Please advise. Answer Just another option using a CROSS APPLY and an ad-hoc tally table Example Returns
check date in create table sql
edit: version 8.0.20 I’m learning sql just now, I try to fix it but I’m not able to do it. I have 3 table This is an easier scheme but it’s enough. The return_date must be less than delivery_date + 30 days I tried to use a check on return_date but no work, so I created a view to select
MySQL Running Total By Group, Time Interval
I would like to take a table of customer orders like this: And create a table calculating a cumulative running total by week, segmenting the weeks by 7 days starting at the earliest date (2020-03-01, 2020-03-08, etc.). Something like: Thanks for the help! Answer You can use aggregation and window functions (this requires MySQL 8.0). It is easier and more
SQL Subquery with aggregate function – seeking alternative
My table (Table1) I did a sort of Pivot and it’s fine: http://sqlfiddle.com/#!18/45b9d/1/0 Now I need to calculate the difference between measures, to get something like this: But if I don’t use an aggregate, the result brings me null cells – http://sqlfiddle.com/#!18/45b9d/5/0 And if I do use it, I get the message: Cannot perform an aggregate function on an expression
SQL Date range by month returns in multiple rows
I am looking to get the count of entries by the month. However, this is returning the total count. I would like it to be something like. Month —– Count January —- 500 February —- 600 If I can’t get the month in there, thats fine, but I would definitely like to have it so the count has its own