I have a table where I want every parent to be mapped to every child within each group. Input: Output: So within each group, I want every value in parent to map to every value in child. If there are no values in child for a group, I want that group completely omitted (as shown where group_id = 3) I
Tag: sql
How to get the minimum value for a given time-period
I have a table with equipment failure and resolved date. Until the failure is resolved, entries for each day will show as failed. Once the issue is resolved data will start from the next failure date. Below is an example I want an output which will give me the first failure time for each resolved timestamp li…
Join two SQL/BigQuery tables that do not contain the same columns
I have two queries that create two separate tables, pulling on several foreign keys. Simplified and using retail food as an example, Table 1 looks like this: Transaction ID City Store Item Description 12320 Boston Joe’s Shop 12305 Banana 12321 LA Bob’s Market 12306 Apple 12322 NY Suzy’s Corn…
pyodbc is returning binary data in char field
pyodbc with driver “iSeries Access ODBC Driver” is returning binary output, Ex: original data in the table: B06300 what it returns: b’xc2xf0xf6xf3xf0xf0@@@@@@@@@@@@@@@@@@@@@@@@’ My code: I tried putting add_output_converter and encoder to connection but didn’t work Answer I suspe…
SQL Query, list from BOTH values?
Pretty sure this can be answered quite quickly but I just can’t seem to find a solution online. Might I add also (if you haven’t already figured out) that I’m a complete beginner. The following query lists all movies starring Johnny Depp and all movies starring Helena Bonham Carter. How do I…
How to use refer to multiple id’s when using JOINs in SQL
I try to display the number of reviews which an employee provided and the number of reviews which he received. I try to do something like this, but in my output table (3) I receive incorrect data. I believe that this happens due to the wrong reference: however, if I reference it like this: then nr_of_reviews_…
SQL write a query, question from interview problem
At the beginning I need to mention that I am not very good at SQL so I would like to ask you. Here is a tables relation: tables What I need to do with them is “Show name, surname and number of movies those directors (Reżyser means director), who made more movies that the average number is for all direct…
How to pipe window function output directly into a new window function in SQL?
I am new to SQL and I have the following query: This doesn’t work due to no such column: MyMax. Even though from my understanding the column for MyMax is being created on the fly, I’m guessing SQL still isn’t able to use its values immediately as an input into the next window function I alre…
SQL/Presto expanding a list column into multiple rows
Given a hive table like How can I create a secondary table like Answer This is a textbook case for unnest: Output: a bb 1 1 1 2 1 3 2 2 2 3
call an forEachActivty from a body Json of an webActivtity
I want to use a pipline ADF to call an API REST which used an sql table and extracts one or more files. API should return 3 files if the table contains 3 different regions, for this reason I used the following activities: A lokupctivity : it’s a query ( distinct on the column Regions) to get all the reg…