Amazon, the renowned online retail platform, requires customers to create an account to browse and purchase items of their choice. In this analysis, our objective is to pinpoint the new customers who have joined in the current month.
Hint: We can consider the date of a customer's first transaction as their account creation date, enabling us to distinguish between new and existing customers
Input Data:
Expected Output:
Data Script:
CREATE TABLE dbo.CustomerTransactions
(
CustomerID NVARCHAR(250),
CustomerName NVARCHAR(MAX),
BilledItems NVARCHAR(MAX),
TransactionDate DATETIME
)
INSERT INTO dbo.CustomerTransactions
VALUES
('1000A','Alex','BoatHeadPhones, Samsung Mobile',GETDATE()-200),
('1000A','Alex','ITC Notebooks, Pencile',GETDATE()-150),
('1000A','Alex','Filla Shoe, Bata School Shoe',GETDATE()-58),
('2AB01','Shinde','Laptop',GETDATE()-10),
('2AB01','Shinde','Laptop Charger, Laptop Bag',GETDATE()),
('89CR0','Naani','Shorts',GETDATE()-3),
('89CR0','Naani','Boost, Good Day Bicuts',GETDATE()),
('Y87AC','OutByte','Avast Anti virus',GETDATE()-90),
('Y87AC','OutByte','T-Shirts',GETDATE()-71)
SELECT * FROM CustomerTransactions
Please try to answer the question, if you still not able to get it click below show button to see the answer.
No comments:
Post a Comment