Merge two queries/interfaces into one
I have two queries of which I need to create one, unified without any filters applied on them. The code for each is as below
Fill value from previous date if current date is not availables
I have two tables – sales
and currency_rate
. I want to fill col CurrRate
to each transaction line from Sales
based on the the month as from table sales
col [Date]
and table currency_rate
col CurrentPeriod
. If it happens that chain of dates is break in the table currency_rate
I want to fill previous CurrRate
value of previous month to the actual line of Sales
. What is worth to mention that both CurrentPeriod
and PreviousPeriod
are datetime and Date
in table Sales
is int like 20240701
UPDATE a column from table A if A.column values contain table B.column
I’m using Spark SQL. Table A contains two columns – CVEs
, KEV
. Table B contains column CVE
. I would like to set A.KEV
to 'True'
if A.CVEs
contains B.CVE
(not equals). In SQL Server, this would be something like