I love a good challenge, but this one has been breaking my head for too long. 🙂 I’m trying to build a query to get dates intervals, grouping the information by one field. Let me try to explain it in a simple way. We have this table: I need to get the intervals a soldier spent on each ranking, so
Tag: oracle
Oracle SQL in HR Schema Write a query to display “How many characters are there in each employee’s last name before the first ‘e’ or ‘E’ appears?”
Write a query to display “How many characters are there in each employee’s last name before the first ‘e’ or ‘E’ appears?” Answer That is pretty much what the built in function INSTR() does – well, technically, it finds the positions of the ‘e’ so what you want is one…
How to group by month and year?
I have a table PURCHASE with a date column PURCHASEDATE which is in DATE format. I’m trying to get the purchases grouped by month and year. To do so, I try with: I have also tryied with GROUP BY EXTRACT(MONTH FROM PURCHASEDATE), EXTRACT(YEAR FROM PURCHASEDATE) but neither worked. I’m rusty with SQ…
Update column values with result from group values (MIN) of linked table
I have two tables Table 1 (main) and Table 2,connected with T1. I need to delete double entries in Table 1. TO do that before any delete in T1 I must delete or update the data in T2. The option chosen is to update T2 data to point with entries not to be deleted in T1. SQL Problem : I
Why to use Correlated Subqueries?
As far as I’ve seen, correlated subqueries can be re-written using multiple-column subqueries or joins. And they usually perform better than correlated subqueries. So in which possible scenarios a correlated subquery can be a better option or the only option? (I use Oracle Database) Answer Oracle has a …
Optimization of Oracle function
I wrote a function in the oracle database that calculates saldo and finds the date of the operation. Here’s how it works: He will receive Start subtracting the first cell of TURNOVER_DEBIT column …
UNION ALL query using WITH statement breaks
I wrote a query using with statement and union all. But, I am not used to writing complex queries. It keeps breaking in the union all. Please point me where it is wrong? WITH t1 (source, target) AS ( …
Is there a way to resolve this constraint problem? [closed]
I am trying to update an object and I’m getting these errors: SQL Error: 2290, SQLState: 23000 2020-11-26 09:05:18.187 ERROR 6395 — [ XNIO-1 task-62] o.h.engine.jdbc.spi.SqlExceptionHelper : …
How can I change the layout/structure of my table?
I currently have a table with 3 columns in it. The columns are best described as group_id, task and task_count. There are up to 15 possible tasks and over 500,000 group_ids. The task_count is the number of events that took place in a group_id for that task. Currently, the table looks like this: So in group 55…
Oracle : Not a valid function or procedure name
I have to create a procedure that inserts a person to table: When I call the function: I get the error: Answer You can use: Which, if you have the table: Then you can do: And the table contains: ID_OSOBY | IMIE | NAZWISKO | WIEK | STAN_CYWILNY | TELEFON | PESEL | ID_ADRESU ——-: | :— | :̵…