title: Query to pull second order date for a customer(SQL 2014)
body: <p>I have a schema with customers, orders and order dates.
  A customer can have orders in multiple dates. I need a calculated member to bring the first order date and  the second order date with other associated metrics. 
  I was able to get the first order date and associated data using min(order date) as a first order but having issues querying for the second order date. Any suggestion would help! Thanks  </p>
  
  <p>my query </p>
  
  <p>---I have all the information in one table so my query looks like              </p>
  
  <p>Select  customerid, order id, min(orderdate) as firstorderdate,...
  From customer  Where first ordedate between 01/01/2015’ and  GETDATE()  </p>
  
  <p>(since I only want those customers who made their first purchase this year) </p>
  
  <p>Query their second purchase </p>
  
  <p>Select customerid, orderid, orderdate from ( select  customerid,
   orderid, orderdate, rwo_number() over (partition by customerid,
    orderid order by orderdate) rn from customer
  Where rn&lt;=2</p>