i have following query SELECT “Nomenclature”, CASE WHEN ad.”Title” = ‘Кухня’ THEN au.”Value” ELSE NULL …
how to drop multiple functions in Oracle
I want to drop multiple functions from my database at a time in Oracle’s SQL developer. Is anyone has an idea how to create a script for that? Answer Well, the static option to drop the functions (sometimes considered more secure as you can double-check what you are removing) consist of two steps 1 R…
SQL how to find the product group with highest porportion of expensive items
I have a table with products, product_group and price level. How can I find the product group with the highest porportion of expensive items? I have tried this query, but it keeps all price_levels, not just the expensive ones. Essentially, I want to divide the number of expensive items in one product group by…
Randomly select orders per customer from database
DB-Fiddle Exptected Result: I have a huge database and need to extract some data from it for a case study. The problem is that I need to extract the full year of the data because I want to be able to conduct a monthly analysis in the case study. Therefore, I can not limit the extract with dates or LIMIT.
Getting the latest status of user before every calendar Date in SQL
I have 2 tables as below: Table 1: UserID DateEntered Status 1 29/03/2021 a 1 30/03/2021 b 1 31/03/2021 a 2 01/04/2021 a 3 02/04/2021 c 2 03/04/2021 c 3 04/04/2021 a 4 05/04/…
SQL Query to find a group of rows having all of them a certain value in one of its fields
Given table: +—+——-+——+—+ |id | attr | fker |did| +—+——-+——+—+ |1 | attr1 | 5 | 1| |2 | attr1 | 17 | 1| |3 | attr1 | 3 | 2| |4 | attr2 | 31 | 2| |5 | attr2 |…
Failed to add the foreign key constraint 2
CREATE TABLE Program( name VARCHAR(64) NOT NULL, abbreviation VARCHAR(16) NOT NULL, PRIMARY KEY (name) ); CREATE TABLE Student( ssn INTEGER CHECK (ssn > 0) NOT NULL, name …
Select only products that are active via query from two tables
I have a query that provides me with a list of productId:s that I then match with a products table.. But how would I adjust the query to give me only productId:s that are active (active=1)? Answer You can use join:
Populating a recordset between two positions in a table using MYSQL
I’m trying to write a query that will only return a recordset between 2 positions in a table For example, using Excel to demonstrate, populate a recordset between positions 3 and 7 I thought about using BETWEEN with the ID field, but there may be times that a record has been deleted and the ID field aut…
Subquery – define select list. The subquery returns the same value for each result line
do you know what I have done wrong? My subquery is returining the same value for all lines. Thanks a lot in advance for your any advice! 🙂 Answer I think you just want conditional aggregation: