Skip to content

Tag: oracle

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…

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 …

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 ( …

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 ——-: | :— | :&#821…