Skip to content
Advertisement

Tag: date

Input selected row and ignore duplicate row

I have a problem that I need to insert a selected row from the table to another table based on last_update data or last_transaction_product. last_update is the data updated from the table, and last_transaction_product is the latest transaction from my shop, and then my row has duplicate data but has a different last_update column here, this duplicate data must not

How to compare DD/MM dates in BigQuery?

I’m trying to compare two dates without the year, only the day and the month (DD/MM) when for example 30/04 < 02/05. I want to be able to say wether a date is previous or not to another date based only on the day and the month without paying attention to the year. I tried to use FORMAT_DATE(“%d/%m”, DATE(“2021-04-30”)) <=

Select most recent record (with expiration date)

Let’s say that we have 2 tables named Records and Opportunities: Records: RecordID CustomerID CreateDate 777 1 1/1/2021 888 2 1/1/2021 999 1 2/1/2021 Opportunities: OppID CustomerID OppCreateDate 10 1 12/31/2020 11 1 1/10/2021 12 2 2/1/2021 13 1 4/1/2021 14 1 8/5/2025 Desired Output: RecordID CustomerID CreateDate #Opportunities 777 1 1/1/2021 1 888 2 1/1/2021 1 999 1 2/1/2021

Find nearest day of week for a given date and day of week

For a pair of dates (date1, date2) = (Fri 2021-01-01, Wed 2020-01-01) I need to extract the day of week from date1 (Friday in this case) then find the nearest Friday (or whatever) for date2. The result for the above pair would be Fri 2020-01-03 (2 days after that Wednesday) and not Fri 2019-12-27 (5 days before that Wednesday). There

Select data using closest date

I have two tables like below: table1 table2 I have to calculate TotalPrice (price x Quantity) from each ID for the date ‘2017-07-28’ but condition is that: if no price is available for a given date, the price closest to but before the date should be used. I have tried the below query but its not giving the proper output.

SQL date scenario for getting previous month’s data to-date on the 1st of month, then drop last month

I’m trying to recreate an existing View in Snowflake (originally in SQL Server). I need to get last month’s data which is easy enough, but here’s the scenario: On 3-1-21, it should retrieve 2-1-21 to 3-1-21, but then starting on 3-2-21, it should only show 3-1-21 to-date, as our month end reporting goes out on the 1st of the month,

Advertisement