Forum Discussion
elmira_mkhyahoocom
Jul 11, 2023Copper Contributor
SQL Query
Hi there,
I want to write a query for below question:
Write SQL that returns all rows in the customer table that:
a) Have joined in the past 4 days
b) Have a valid email
Customer | ||||||
CustID | firstName | lastName | JoinDate | EmailValid | EmailAddress | Mobile |
1 | nas | gil | 2022-10-20 | 1 | email address removed for privacy reasons | 0444566989 |
2 | sam | both | 2022-10-10 | 0 | email address removed for privacy reasons | 0465789678 |
3 | rick | marc | 2022-10-15 | 1 | email address removed for privacy reasons | 0446578234 |
Transactions | ||||
TransactionID | CustID | TransactionDate | StoreID | Total |
1 | 1 | 2022-10-18 | 1 | 15.15 |
2 | 2 | 2022-10-19 | 1 | 10.50 |
3 | 3 | 2022-10-20 | 2 | 25.75 |
4 | 1 | 2022-10-20 | 3 | 30.00 |
- olafhelperBronze ContributorAnd what's the problme writing a query; you have all required informations in table "Customer"?
- bake13Microsoft
Hi elmira_mkhyahoocom --
You can use a query similar to the one below to obtain the desired results. Take care.
SELECT FirstName,LastName,JoinDate,EmailAddress,Mobile FROM Customer WHERE JoinDate > DATEADD(day,-4,GETDATE()) AND EmailValid = 1