I was trying to script out all the SQL Server Agent jobs for category ‘Data Warehouse’ into a single file I was able to do it using PowerShell, where every single job creates a single file. But I need one file for all the SQL Server Agent jobs under category ID = 100 (or Category : = ‘Data W…
Google BigQuery SQL: How to fill in gaps in a table with dates?
Data Table: Dates Customer Subscription 20/02/2020 A free 21/02/2020 A free 22/02/2020 A free 23/02/2020 B free 23/03/2020 A full 01/03/2020 B full 01/03/2020 A full 02/03/2020 A full Need to fill gaps in dates by the value in the previous date Output: Dates Customer Last Subscription 20/02/2020 A free 21/02/…
get both the total count of enrollments and the count of sigtrack enrollments in one query
I have a table with following schema: Column Type Description user_id INT A unique identifier for a student. session_id INT A unique identifier for a course. is_sigtrack CHAR …
UNION two SELECT queries but result set is smaller than one of them
In a SQL Server statement there is SELECT id, book, acnt, prod, category from Table1 UNION SELECT id, book, acnt, prod, category from Table2 The first …
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 …
BigQuery SQL : Dynamically Concat all rows in column by key
I have a table like this: Customer Plan/Date A free (20/01/2020-01/02/2020) A starter (01/02/2020-01/03/2020) A full (01/03/2020) B trial (02/03/2020-05/04/…
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…