Oracle sql query to group two sets of dates if sequencials

I have the next table: EMPLOYEE CODE START_DATE END_DATE 02097368 F7H3 09/07/2018 20/10/2018 02097368 F7H3 21/10/2018 05/01/2019 02097368 F7H3 06/01/2019 12/01/2019 02097368 F7H3 13/01/2019 02/02/…

Convert Timestamp to minutes in Oracle after a subtraction

I’m trying to get the minute value from a Timestamp after a subtraction First I made a subtraction: Current Time – Target Time(INSP_FIN_DT) ( TO_TIMESTAMP(TO_CHAR(SYSDATE,’YYYY-MM-DD HH24:MI:SS’),’…

How to insert a inner join from 3 different tables

I am making a view pulling data from 3 different tables for the query. Here is my code so far, I’m just not sure how to integrate the inner joins since I already have a select statement, I can’t …

Oracle SQL Error : Unable to execute Subquery

I am trying to execute below Oracle SQL query select m.*, n.region_building_count from (SELECT a.BUILDING_ID as “Building Id”, d.Building_name as “Building Name”, d.ADDRESS …

How to add escape $ in Zend framework query

I need to add escape ‘$’ in zend framework. expected query: SELECT * FROM V_HOME_SEARCH sv WHERE sv.NAME LIKE ‘%gar$_%’ ESCAPE ‘$’ I tried this: public function selectData($str){ $select = $this->…

SQL – Compare rows based on date and transpose difference

Scenario: Table ‘HIST’ RID VALUE HIST_DATE 1 V111 2019-01-01 1 V112 2020-02-11 1 V112 2020-03-08 1 V113 2020-04-11 1 V114 2021-03-15 2 V211 2020-04-11 2 V211 2021-03-16 3 V311 2019-05-01 3 …

Why do I get an Error when I try to rename a table after FROM?

When I simply try to retrieve all of the rows in my table EMPLOYEE like this: SELECT * FROM EMPLOYEE AS emp; I get the following error: ORA-00933: SQL command not properly ended 00933. 00000 – &…

How to find a destinct values in a table that are larger than all values that reference it?

I need to find the names of bosses who were hired after all the hired date of all their subordinates. Here is what I have got so far: SELECT DISTINCT TRIM(boss.first_name || ‘ ‘ || boss.last_name)…

Oracle SQL – Outer join based on concat

I need to cross join two tables but the joining conditions are: Select FutureInventory.Item, To_Number(Concat(Location, Channel_Id)) Location, From V_CUST_FUTURE_INV_POSITION FutureInventory, …

BOM Explosion with Blanks

I have a simple BOM table that contains a parent and a child column. Every row contains values. There are no blanks. To bring that table into a BI-Tool I need to add blank values for the parents, like …