I am making an app where people can select a song and listen to it. Whenever someone plays a song it should display the percentage of the how much youve listened in an overview. I have the following …
Tag: sql
Calculate order sequence in BigQuery
I am new to BigQuery SQL and struggling with calculating an “order sequence” from a table of customer orders. In my example, I am working with customer purchases, where I have the sales …
sql oracle – select availability between dates
I have the below table INDISPONIBILITY, that respresents the availability of teachers, for example the teacher a1 is not available from 25-Jan-21 to 25-Jan-21 from 8:00 to 12:00. I want to select …
Convert PostgreSQL COUNT … FILTER query to SQL Alchemy
I’m new to SQLAlchemy, and I would like to convert this PostgreSQL query: I have already tried this: Thank you in advance for your help Answer Thanks to @IljaEverilä’s comment, here is a more direct answer: (Original answer) I’m not sure if SQLAlchemy’s postgresql dialect specifically …
Manipulate data in SQL (backfilling, pivoting)
I have a table similar to this small example: I want to manipulate it to this format: Here’s a sample SQL script to create an example input table: CREATE TABLE sample_table ( id INT, hr INT, …
“not like” in DolphinDB SQL
It returns the following error message: Does anyone know what I can do with it? Answer It doesnt support not like. Use not as follows:
How do i pivot this redshift table? (Revised question)
Note: This is a revised version of another question – i realized i didnt have complete requirements (sorry about that!) I have a Redshift table called metadata with the following columns: id key value 1001 code1 my value 1001 code2 another 1001 code3 yet another 1002 code1 new one 1002 code2 here 1002 c…
Determine time duration based on events without using loops
I have a table with timestamps of 5 different types of events (start, stopped, restart, aborted, and completed). The given table looks like this: Time EventID Event 7:38:20 1 start 7:40:20 2 stopped 7:48:20 3 restart 7:50:20 4 aborted 8:00:20 1 start 8:40:20 5 completed 8:58:20 1 start 9:00:15 4 aborted I wou…
How best can I to pivot my redshift table?
I have a Redshift table called metadata with the following columns: id key value 1001 code1 my value 1001 code2 another 1001 code3 yet another 1002 code1 new one 1002 code2 here 1002 code3 last 1003 code1 hello 1003 code2 goodbye 1004 code2 now 1004 code3 then I’d like to have a query that return it as:…
Test ARRAY whether it contains ALL or NO elements of given ARRAY
Suppose we have an array: With the operator <@ I can query whether the left-operand is a sub-array of the right-operand: The above works greatly but now let’s take the following case: In this case the above will return false as expected. Do we have an operator which says the following: either the lef…