Context I want to use the HANA HIERARCHY_TEMPORAL function to work on a SAP KNVH hierarchy with time intervals ; When simply used in a SELECT query, this works fine ; When otherwise using the very same query but assigning it to a table variable, the result is inconsistent. My problem This anonymous block work…
Tag: sql
Python(Flask,JayDeBeApi) RuntimeError: No matching overloads found for prepareStatement
as mentioned in the title i get this error when i try to execute a prepared statement. The full error is: As far as i can understand is, that propably that since i am trying to use a prepared statement, that the compiler can not find something to overload the ? placeholder. Code snippet: The error seems to ha…
SQL statement to count occurrences in list
i would like to run an SQL query to calculate the number of passes and fails in a list. I’ve created a scenario with students and grades to better explain my problem. I have 2 tables one being the student table studentid firstname lastname 1 Sponge Bob 2 Patrick Star and another table being the grades s…
How to calculate difference in dates for column with smallest value
I have a table that contains 3 column dates: CREATED, CLOSED and EXPIRED. I need to calculate the difference in date between either CLOSED or EXPIRED and CREATED. I need to select the SMALLER value between CLOSED and EXPIRED and then calculate the difference to CREATED. If they have the same date, I need to s…
Add join and search in columns for any string
I have these Postgres tables: I use this SQL query: How I extend this SQL query to search also in table employees by employee id and filter the result by any character found in table columns first_name and last_name? Answer You can join the new table using employee_id:
How do I add number of days from original dates in new column
Hopefully a quick one on BigQuery I’ve tried intervals and days but can’t quite seem to get what I want. For date row on the example table below I want and adjacent row in a new column that just adds 42 days to the original date and time (time is always 00:00:00 if that helps). Desired output belo…
Show All Duplicate Records QUERY
What is the query that will show all the records that have multiple names? For example. Table 1: Desired result: Answer You can use GROUP BY and join result to origin table
LIMIT and OFFSET returning repeating results
There seems to be a bug in my query that causes results to repeat when I increment the OFFSET value. It is supposed to show 20 results per page. Only 3 results match what my query is looking for, but for some reason, some of these results repeat themselves even though they should only appear on the first page…
Calculating win streak from list of fixtures
I have a table fixtures with a list of matches played between two players in each, identified by their ID. I’m trying to use the table to calculate rolling winning/losing streaks for each player, but I’ve been having issues with my query below (see more on SQL Fiddle): Below is the desired result,…
Return only ALL CAPS strings in BigQuery
Pretty simple question, specific to BigQuery. I’m sure there’s a command I’m missing. I’m used to using “collate” in another query which doesn’t work here. Desired return: JOHN@EMAIL.COM,STACY@EMAIL.COM Answer Consider below If applied to sample data in your question …