Skip to content

speed up join on string field

I have a table with data like the tableA example below. the date column is formatted as a string. the close column is an integer, ticker is formatted as string. I’m trying to run the query below on a …

SQL Query for multiple joined tables

I am querying against a SQL Server database and I’ve been struggling to get the result set I want. I feel like it is possible but I’m just unable to do it. Here is how the DB is layed out. I’d like to return a result set that looks like this: I’ve unsuccessfully tried using CTE’s…

SQL query to do the lookup

I have a table called “Branch” and another table called “Role” as per the screenshot and I want to have the output as mentioned in my output screenshot. I want to create a view …

Impala incompatible return types in case when statement

I am running an Impala query and try to use a case when statement: It complains This however works fine: As the error message indicates, PRTCTN_ALLCTD_VL is of type decimal(38,10). Any advice is appreciated Answer This is a curious problem, one that I would not expect. A case expression returns a single type …

Using declared variables in SQL Oracle query FOR LOOP

I’m attempting to write a query script where I declare a variable and then use them in a select statement in Oracle SQL. Basically script should check if parent tables’ entries are used in referenced table or not. if not –> delete the entry from REF table. So far I have this So far LOG_MS…