Skip to content

Tag: sql

Expanding jsob array in PostgreSQL to produce analytics

Imagine that we have the following table using jsonb on PostgreSQL: And the following data is available: Is it possible to expand the JSON array to 2 columns similarly to what PowerBI expand does and get the following result? firstName surName bookName William Shakespeare Hamlet William Shakespeare Juliet Aga…

Nested SUM with OVER clause

I am trying to understand how nested SUMs with OVER clause work in SQL. Let’s say i have the following schema in my DB and suppose that i want to calculate the (number of deliveries of each region)/(number of deliveries of the state) on the same year. The query to do the calculation is: I can’t un…

Interpolate Multiseries Data In SQL

I have a system that stores the data only when they are changed. So, the dataset looks like below. data_type_id data_value inserted_at 2 240 2022-01-19 17:20:52 1 30 2022-01-19 17:20:47 2 239 2022-01-19 17:20:42 1 29 2022-01-19 17:20:42 My data frequency is every 5 seconds. So, whether there’s any times…

Multiple column updates in one statement – Microsoft SQL Server

I am trying to update three columns depending on three different conditions in Microsoft SQL Server. See the following example for details How would I refactor the query if I want to do it in one update statement? Appreciate your help! Answer You don’t really need the where clauses. And we can take adva…

vb.net select statement failing

I have this code to populate a DataGridView (DGV) the goal is to only populate the DGV with data from the LinkTable where one of its fields ytSiteType is equal to a global variable set on another form. The variable is gvSLT and I have tested that gvSLT makes the trip to the new form with the correct value. I