Oracle sql query to group two sets of dates if sequencials

Tags: , , ,


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/...

Iterate an array using only select query in teradata

Tags: , ,


I'm trying to achieve the output table using the input table. The input table contains id and name where id has the numerical values and name contains JSON value. I can get the output by writing a ...

Tags: oracle sql view

How to insert a inner join from 3 different tables

Tags: , ,


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 ...

Tags: mysql sql

Truncate a column that is the result of CONCAT function?

Tags: ,


I'm trying to truncate a column that I have created in my query to display only 15 characters, however I don't know how to. In a table (yes), in a query (no). How would I write my code to do this? ...

Select values for a column only if there are no rows with that value that satisfy a condition

Tags: , , ,


I have a table that stores logs of http fetches, let's say we have two columns: fetch_url and success. A few example rows: success fetch_url TRUE A FALSE A FALSE B FALSE B FALSE ...

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

Tags: , ,


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 - &...

Tags: mysql sql

How to compare counts from subselect?

Tags: ,


I want to compare the count between two tables. Or more to say, output if the count from table1 is greater than from table2: SELECT c1 > c2 FROM (SELECT count(*) from table1) as c1, (SELECT count(*)...

Tags: postgresql sql

Selecting cities that have a combination of products in SQL

Tags: ,


I have the following dataset, that have the prices for many products and cities: CREATE TABLE my_table ( the_id varchar(5) NOT NULL, the_date timestamp NOT NULL, the_city varchar(5) NOT ...

MS Access query that includes a join to itself (using a subquery) and reports values that do not exist (null values)

Tags: , , ,


I have the following table named PRICES: VERTEXID TIMEID PRICE 6001 20191231 104.3 6001 20181231 115.3 6001 20171231 138.3 6001 20161231 122.3 6002 20191231 102.3 6002 20190931 123.3 6002 ...

Tags: sql sqlplus

How to subtract Expenses from Gross Profit from sql plus query?

Tags: ,


I have to calculate Net profit So i have following query. How can i subtract "Total Expenses" from "Total Gross Profit": SELECT SUM(orders.quantity * orders.price) AS "...