So basically I’m trying to write something that prints the customer’s name and area code if they have made a booking within the last 6 months of the current date. My code looks like this (it has to be a subquery, not using join) Yet it doesn’t work, but I can get it to work using a join function, but
Tag: datetime
Order count per ID and calculate time between orders in BigQuery
I am working with customer purchase data and am trying to write a query in Google BigQuery that sorts all purchases by date and adds a purchase/order count per customer (order_count). Also, I would like to calculate a time-delay (in days) between the orders of one customer (purchase_latency). My query currently looks like this: The result including “order_count” and “purchase_latency”
Why do double quotes influence result in compareing datetime?
Why do these two results dont return the same results? Can anyone explain why? (addtime is datetime type.) Answer This does not do what you want: Unquoted 2020-10-10 is an arithmetic operation, which returns integer value 2000. You are then asking MySQL to compare it with a date, so it tries to convert the integer to a date, which yields
Including only one row in sql [closed]
What I’m trying to do is take these records that looks like this: ID NAME STARTDATE ENDDATE EnrollmentMonth 1 PETER 20200705 20200729 20200701 1 TONY 20200730 99991231 …
Indexing an SQL table by datetime that is scaling
I have a large table that gets anywhere from 1-3 new entries per minute. I need to be able to find records at specific times which I can do by using a SELECT statement but it’s incredibly slow. Lets say the table looks like this: I’m trying to get data like this: I also need to get data like this:
datetime.datetime conversion to datetime
I have defined a column in SQL Server as ldate with datetime data type and accepting null values. I’m trying to send data from my local machine using python and pyodbc. I have date like 20-01-2015 in string format. When I try to send data it throws an error: pyodbc.DataError: (‘22007’, ‘[22007] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Conversion failed
Get the logs of the current week in postgresql
I need to get the logs of the current week in postgresql, I have tried to use the native mysql functions yearweek for that, but here in postgresql it is different This is my table CREATE TABLE …
PostgreSQL, summing multiple date columns over multiple rows
Let’s assume the following table: CREATE TABLE assumption ( datetime_1 TIMESTAMP, datetime_2 TIMESTAMP, datetime_3 TIMESTAMP); Now I want to know the total amount of times a month is set in any row …
Date distinct count over week
Im trying to get a distinct count of user ids logs per day with every week as a partition for the distinct identification. e.g. if one user logs on Friday/Saturday of week 1, and on Monday/Friday of …
How to pull data for past x weeks dynamically in redshift?
I have a below query which I run gives me the single count for previous week which is Week 43. Current week is 44 as of now. As of now the output I see is this which is for Week 43- Now I am trying to make this query dynamic such that it can give me count for past 6