This query displays performance of 3 endpoints combined (decided using some priority) over a series of days in the period of last 2 weeks. Just for display in the dashboard, I need to combine the values of the dataset using something like group_concat. This seems to be working fine for String type column. How…
How to transpose row to columns in Oracle as shown below using Unpivot?
Source Table Cost Category Cost Category Type Q1-2020 Q2-2020 Q3-2020 Q4-2020 Employee Impacted Period Cost 10 20 0 4000 Achieved Result Cost Category Cost Category Type Quarter Year Value Employee Impacted Period Cost Q1-2020 10 Employee Impacted Period Cost Q2-2020 20 Employee Impacted Period Cost Q3-2020 0…
MS Access SQL extracting a dataset of latest dates from grouped data
I have the following 3 tables: The first holds actual purchases by Customers, the second is price quotes to a customer for a product and the third shows any interest (Sale or quote) in a product by a …
Error Using the iif statement in MS access
The completion_metric field from this query I made in MS ACCESS keeps giving me zero percent for all the records. I think something is wrong with my IIF statement. Also, how would can I populate a text box on a ms access form with this query. For text-boxes there seems to not be an option to let my record sou…
How to solve “SQL aggregate function not allowed”?
I want to get the cases per million where a table contains “Province Population” and another table “Interim” contains a column that has unique Epid_ID values. I want to divide the count of these “Epid_ID” values with the population where the data type of population is big n…
Getting an output based on conditions and creating a new column and updating it based on a condition in SQL
We have two tables: “riders” and “drivers”. Some riders are also drivers, so will show up on both tables. Each table looks like this: Table riders I have tried this code: Write a query that outputs all SF riders and add a column called ‘flag’ that prints ‘true’ if the rider is also a SF driver and ‘false’ if …
Does Oracle always resolve CTE with clauses even if they are not used in the result set
If I have an Oracle SQL query like this: Will the DBMS actually do the work of resolving/running query2, or does Oracle know that query2 is not required by the final output, so the work of that CTE/with should be skipped? Oracle version is 12c Enterprise. Answer I was going going to say “it’s up t…
What is the syntax error in this simple SQL query for creating a table?
I am trying out IntelliJ’s DataGrip to do some SQL work on a MariaDB database. Somehow i cannot execute the query that was automatically created by DataGrip itself…. Can you help me find the error in it ? The error is I tried to validate the query with an online validator and it seems fine… …
How to retrieve all grand parents at once
I have two simple tables in SQLITE3 (family bonds): “persons” (id, fname, lname) “relationships” (parent/child) I would like to get each grand children along with all their grand parents (from 1 to 4 of them depending on the grand child) so that 1 row result = Thanks to Caius Jard, I&#…
Returning a value before committing transaction and (UPDLOCK, HOLDLOCK)
I need to check if a record exists – if yes: then returns its id, if not: creates a new record and returns its id. I am using WITH (UPDLOCK, HOLDLOCK) in SELECT to prevent from duplicates (it creates lock). I wonder if I should commit the transaction if a record exists in a database for realising the lo…