Oracle several counts over partition

I have the below query which is outputting the below results: SELECT a, b, COUNT(1) count, round(RATIO_TO_REPORT(COUNT(1)) OVER() * 100, 2) perc FROM t1 WHERE condition1 GROUP …

Oracle display number of unique values for column combination

I have the below table C1 C2 C3 A1 A2 A3 B1 B2 B3 C1 C2 C3 C1 C4 C3 For each unique combination of C1 and C3, I would like to keep the first value in C2, but storing the count of unique elements …

Oracle SQL Inserting multiple rows into a table while referencing 2 FK

I’m trying to insert values id_team_FK and id_location_FK which both come from the same table. For example id_team_FK = 4 and id_location_FK = 150. The problem is, id_team_FK must be a randomly chosen …

(Error) ORA-02270: no matching unique or primary key for this column-list

I have the code below and I’m running it step by step: CREATE TABLE registration ( constraint pkks primary key (cod_class, number_rgm), cod_class NUMBER(8), number_rgm …

ORDER BY DECODE: Decode won’t reorder the days like I want it to

I’ve got an assignment where I need to return a certain report and then order it by the day, but I need Monday to be day #1 (by default, Sunday is day #1 in SQL). Here’s my code for the report and the …

Oracle 10g sql query

I have some data like this ↓ T_ID T_PERIOD T_COUNT T_SUM T_UPDATE_COUNT 1 2013-2014 3436 20118043 0 2 2014-2015 4298 27101356 0 3 2015-…

sql oracle – select availability between dates

I have the below table INDISPONIBILITY, that respresents the availability of teachers, for example the teacher a1 is not available from 25-Jan-21 to 25-Jan-21 from 8:00 to 12:00. I want to select …

Create Children and Parent of a Person

I have the following Type Address and PhoneNumber: CREATE TYPE Adress AS Object (Street varchar2(50), PostalC number, Ville varchar2(50)); CREATE TYPE PhoneNumber AS Object (Ind varchar2(3), PhNumber …

No data is showing in object browser in Oracle Apex

I have a SQL table created in Oracle database with 5 records. However, the records are not reflecting in the Oracle Apex Object Browser (table). I tried refreshing the data but no luck. I was able to …

Merge sql throws Unique constraint violation error

I have below two table for which when i query table TEST_RUA: select CLASS, ID_LL, ID_UU, TKR from TEST_RUA where ID_UU= ‘GV9999B12M0’ it returns: CLASS ID_LL ID_UU TKR Bond (null)…