Thursday, 15 August 2013

SQL server 2008: How to get the start date and end date of my data? -


As a newb, I already know that I will be birited to ask this question, but I The answer can not be found here and the site can help with some help ...

I have a table that lists the data on a day-by-day basis, and for example by type

  transaction. Date | Type ------------------------- Update | 11/7/2008 | Cash-out updates. 11/10/2008 | Written check deposit. 11/11/2009 | Cassand check update | 11/18/2008 | Submit Check Deposit 11/19/2009 | CASAD CHECK  

What I am trying to do is the first occurrence of each transaction type, and the last event of each transaction type is. Therefore, I am trying to find out a SQL statement which I can write which will return something like this:

  Transaction | First date End date ---------------------------------------------- Update | 11/7/2008 | 11/18/2008 | Deposit | 11/11/2009 | 1/19/2009 |  

Any ideas? Select transaction, MIN [[date]] as [first date], max

  ([Date]) From the My_Table group for transaction from AS [last date]  

No comments:

Post a Comment