Skip to content

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.

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 …

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’…