Skip to content

Instantly share code, notes, and snippets.

@evandocarmo
Created August 12, 2017 00:40
Show Gist options
  • Save evandocarmo/41bfbd228571e16626dfd38dc9ab67e3 to your computer and use it in GitHub Desktop.
Save evandocarmo/41bfbd228571e16626dfd38dc9ab67e3 to your computer and use it in GitHub Desktop.
/*
1. Write a SQL query that returns names and emails of customers whose credit cards are about to get expired (in the next 14 days). Data model looks like this:*
1. Table Customer (id, name, address, email)
2. Table CustomerCreditCards(id,customer_id, ccnumber, cvs, expirationdate)
*/
SELECT name, email FROM Customer
INNER JOIN CustomerCreditCards
ON Customer.id = CustomerCreditCards.customer_id
WHERE DATEDIFF(CustomerCreditCards.expirationdate,NOW()) <= 14;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment