Skip to content

Tag: sql

SQL DELETE FROM several tables

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…

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…

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