Link to home
Start Free TrialLog in
Avatar of Alex A
Alex A

asked on

SQL query, getting number of days from first record

How would you write a query to get Customer Id, VisitDate, NumberOfDaysFromFirstVisit from the tables below?

Customer
Id      Name
101      Name1
102      Name2
103      Name3
…      …



CustomerVisit
Id      VisitDate      VisitedCity
101      1/1/2017      City1
101      1/5/2016      City2
101      1/3/2016      City3
102      1/1/2016      City1
102      1/5/2016      City2
102      1/3/2016      City1
102      1/1/2016      City2
103      1/1/2017      City1
104      1/1/2017      City2
105      1/1/2017      City4
...     ...                     ...



Thank you in advance.
ASKER CERTIFIED SOLUTION
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial