I have the following tables: dataset, links, files dataset has a field called tiComplete, if it is 0 then the record is incomplete, links and files both have a field “biDataset” that references the record in the dataset table. I’m trying to create a query that deletes all entries from datase…
Tag: sql
Data from the table based on the received
Table Users: id, login, name, age Table views: id, date, user_id, post_id Table other: id, timeD (date), post_id What is already there: Result: date and user_id I need to add in request to display data about the user (login, name, age), the user id is optional and the timeD column Example: date timeD login na…
Getting values based on other column
I have the following data in SQL. Is there a way using SELECT QUERY that we can replace the NULL values in DATE column based on the REF values? Like replace the NULL values with the first available date for matching REF value, without making any change to the database. Expected Result Answer You can do it wit…
Get the first record from Table 2 where timestamp is greater than timestamp in Table 1
I have two tables. EVENT_NARATIVE EventNum SEQ Message Message_Time GRADE_HISTORY EventNum Grade GradeChangeTime The EVENT_NARATIVE Table has a lot of data (millions of rows) and each Event (EventNum) can have multiple EVENT_NARATIVE records. The GRADE_HISTORY table contains thousands of rows and each EVENT c…
Finding computed fields in Firebird 2.5
Computed fields are readonly. I need to find all such fields in specific table. This query solves this problem (returns info if column is computed or not): At least it looks like it solves it, but it seems that returned informations are incorrect. When RDB$UPDATE_FLAG is 0, its computed (readonly). But its 0 …
SQL Server syntax correction [closed]
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers. Want to improve this question? Update the question so it’s on-topic for Stack Overflow. Closed 9 months ago. Improve this question I am trying to create a SQL Server stored procedure but I am getting…
How to Query JSON Within A Database
I would like to query information from databases that were created in this format: index label key data 1 sneaker UPC {“size”: “value”, “color”: “value”, “location”: “shelf2”} 2 location shelf2 {“height”: “value”, “row”: “value”, “column”: “value”} Where a large portion of the data is in one cell stored in a …
Oracle SQL query partially including the desired results
My requirement is to display country name, total number of invoices and their average amount. Moreover, I need to return only those countries where the average invoice amount is greater than the average invoice amount of all invoices. Query for Oracle Database Result: Austria 1 9500 Expected: Austria 2 4825 S…
Best way to merge two SQL queries into one query
I have two small SQL queries that I would like to merge to be a single query that I will eventually use in a stored procedure. I have tried a CASE and IF/ELSE but could not get it to work. Below is the code. What I want to achieve is have the first column ‘Count of Open Order Lines’ based
I need help writing a query that shows the amount of orders for each month of the year and also the cumulative amount each year
I am so close to answering this question, but can’t figure out the final bits. I am using the AdventureWorks2019 database. My code is: I cant figure out how to order the ‘over’ part of the query. I know it needs to be “rows between unbounded preceding and current row”, but becaus…