Skip to content

Tag: sql

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 …

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