troubleshooting Question

sql query to get age as of a given date

Avatar of johnnyg123
johnnyg123Flag for United States of America asked on
Microsoft SQL ServerSQL
8 Comments3 Solutions34 ViewsLast Modified:
here is some sample data from a table named Customer

CustId   Birthdate
1            05/07/1970
2            05/07/1970
3           05/07/1970


here is some sample data from a table named OrderHistory

CustID    OrderDate        OrderAmount
1              05/07/2019      200
2              05/06/2019      300
3              05/08/2019      400



Trying to write a query that will return the age of the customer as of the order date

in example above, query should return

custid  orderdate           ageasoforderdate

1           05/07/2019       49
2           05/06/2019      48
3           05/08/2019       49
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 3 Answers and 8 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 3 Answers and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros