I’m having an issue on how to add the Offset to the EventDateTime. Is there a way to do this? I would convert it to a decimal number but cannot because 5:30 is not 5.3 hours, it’s 5 hours and 30 minutes. The data is shown below with the expected output. Please help if possible. Sample Data: Expect…
Tag: sql
Linking two tables where the same value exists, without Primary key – SQLAlchemy
I have the following tables defined (very simplified version): I am using BigCommerce API and have multiple order_ids in both tables. The order_id is not unique globally but is unique per store. I am trying to work out how to link the two tables. I do have a Store table (shown below) that holds the store.id f…
Presto SQL – Looking to explode Table of IDs to include predefined row numbers
Apologies if this title was a bit confusing. It’s tough to articulate this problem in a sentence. Here is my current table I’d like to explode this table to look like this: Any help would be much appreciated. Answer You want a cross join:
Finding last and second last date and corresponding values
Consider the following schema (fiddle): For each meter.id I need to find the latest reading date, value, and the value difference vs previous reading. For the sample data my output would look like this (plus some other columns from meters): meterid latest value delta value 1 20090403 399 99 2 20090403 288 44 …
MS SQL return single row case dataset without GROUP BY clause
I have a data set of ActivityDate which is a datetime field and EngineHours which is a decimal field. I want to return a single row of data that brings back the average number of EngineHours on each day of the week. The dataset is pretty big so the best performance is likely to be the most ideal, the script
What is the issue in below sql query? [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 1 year ago. Improve this question I am beginner in sql. Anyone please tell me the problem of my customised query. Error Code: 1…
Dramatic decrease in performance for Postgres query on Google SQL compared to my laptop. Why?
A rather complex (depending on standards) query running on a table with about 1M records. Creating some temporary tables and building arrays and jsonb. On localhost I get average of 2.5 seconds. On Google SQL I get 17-19 seconds. Note: Other queries, like simple selects, are faster on server than on local. As…
IIF statement to filter Access Query with checkbox
I’m working on a search form based off a single table. I’m working primarily in the query design view. I’d like to have a checkbox on the form so if it is checked (true) it will only return records where the setID is Null. If unchecked (false) it will return all records regardless of if ther…
Relational Model – DBMS
I was going through some exercise problems to check my understanding of the relational model. According to my understanding, if we are given Album[mid] ⊆ Musician[mid], we can translate it into plain English as “Every album in the Database must have at least one musician”. If my understanding is r…
Postgresql reference a variable within statement
I come across this scenario frequently in sql and I have seen it done, but would like to summarize the case when/when not to reference a new variable within a statement. This doesn’t work – but this does – How can I implement scenario 1? Answer You can use a subquery.