I am using the infamous “CityJail” schema to answer a question “List the names of all criminals who have committed more than average number of crimes and aren’t listed as violent offenders.” Here is my code: but I get an error: ORA-00936: missing expression 00936. 00000 – “…
Tag: sql
PostgreSQL duplicate key value violates unique constraint while using on conflict do nothing on insert
Table def: I have a function that inserts new rows into the database: It fails with the index Although running the relevant insert on its own with duplicate values it has no problem with it. I can’t understand what seems to be the the difference between the function and the single statement? This also w…
SQL – Add in a new table join when all left join – Total beginner [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 2 years ago. Improve this question I need help with adding in an additional join to my query. All the tables are currently left…
How to reset a session in a sql connection pool?
i have a connection pool using javax.sql.DataSource and PostgreSQL JDBC. The process is simple, I’m taking a virtual connection from connection pool, process it, then close the virtual connection (…
SQL SUM of Article-Prizes
i’m an absolute newbie in SQL and want to add up all the Sums of the Articles * ordered amount to a final prize. I tried to calculate the Articles * amount to the “Gesamtpreis” and then the Method SUM() to sum up all the “Gesamtpreis”. Dont worry, the SQL-Code is auto-generated b…
How to run a SQL query in Cloud Formation template to enable Delayed_Durability in AWS RDS
I have a Cloud Formation template to create a SQL DB in the RDS and want to enable Delayed_Durability feature by default in it by running this query: ALTER DATABASE dbname SET DELAYED_DURABILITY = FORCED; Is there a way to run this query right after db instance is created through CF template? My CF template l…
Will Converting my H2 memory database to a SQL database mess up any actual logic on my project? Spring Boot
I am currently using the H2 memory database for my website. Everything is working so far but to progress my teacher said to transition from the h2 database to a SQL since it resets everytime you restart the program. I was wondering if I transitioned, would it mess up any of my logic / code. I know I would hav…
Simple SQL CASE Question – from WHERE to CASE function
Sorry for the noob question, new to SQL here and would appreciate help 🙂 I have this SQL query: Will I have the same result if I use this query? (Am I applying the case function correctly here?) If not, can someone help me fix the query below, if possible? *EDIT The original query actually went like this, and…
SQL – How to call a part of query conditionally
I need to write a SQL query like this: do step1 do step2 do step3 – this step does a lot of stuffs: define variables, use some variables defined in step 1, query a lot of data into temporary table… …
Convert month and year as last day of the month in oracle sql
I have two column – Month and Year in a table. Need to concatenate these to get the last day of the month in date format. For example, if Month =5 and Year =2020, the output needs to 31-May-20. Similarly if Month =4 and Year=19, the output needs to be 30-APR-20. Any idea how this can be done, is there