I am stumped! I have a table that has a field job_date_start — And the DataType is set to DATETIME If I SELECT job_date_start FROM table; from my table the output is: +—————————+ |…
How to join two tables and add a limit
Given two tables in a SQLite database, app_vendor app and I am trying to get 10 ‘names’ from ‘app’ (names of apps) for a given ‘vendor_id’ What am I doing wrong? Answer Your WHERE clause is in the wrong location. You can do: Result: See running example at DB Fiddle.
Sum the results of a DateDiff [closed]
I have a table with 3 columns: SessionRole (varchar(100)), Start Date (datetime2(7)) and End Date (datetime2(7)). I need to calculate a value that is the sum of End Time – Start Time for all sessions …
Applying Logic to Sets of Rows
I want to add logic that calculates price per claim. Below, there are two claims, one for patient 5, and another for patient 6. Original idea is to create a unique list of patient numbers in a …
How to compare two dates from an oracle database
I am trying to select rows from a table based on a date inside the table using the SQL query: SELECT * FROM users WHERE date1 = TO_DATE(’01/01/2020′, ‘MM/DD/YYYY’) . For some reason, this query only …
Select min date record from duplicates in table
Let say that I have this table “contract” which have duplicated records in the “END” column for the same ID. ID Begin End 20 2016-01-01 9999-12-31 20 2020-01-01 9999-12-31 30 …
SQL DATIME convert issue
I have a column that displays data in the following format: 2017-10-11T14:00:56.000+0200 I want to display the date in this desired format: 2018-07-31 13:11:11 The column in the base table is of …
Oracle sql REGEXP to split a string at certain point so as to maintain the meaning- Suggestions required
I have a string for more than 40 characters and wanted to split it into two meaning full strings to set it into two different fields. Example: SELECT ‘THIS LONG STRING HAS EIGHT WORDS SEVEN SPACES’ …
How to get an array of user_id’s being active at a specific point in time based on their latest event in BigQuery?
I have a problem where I’d like to get all user_id’s in the “active” state for each day. An event is recorded only when the state changes for a user. The state for each user_id should be preserved until an “inactive” event is fired (see example data and outcome). Different …
SQL rolling average that restarts on gaps
I have values that come in every 1 hour and I need to do an 8-hr rolling average. The catch is that this rolling average has to “restart” when there is a gap. Please see the table below (my desired output), as you can see, the value for 14:45 is missing, so the average for 15:45 is that row’…