Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
ranvir_2k
Posting Yak Master
180 Posts |
Posted - 2014-10-13 : 12:04:51
|
Hi all,I have a table with data like the following:ClientID InvoiceDate1 2012-01-011 2013-01-012 2012-01-012 2013-01-013 2012-01-013 2013-01-01I would like to return a distinct ClientID and also the minimum InvoiceDate for that ClientID, so that the data looks like this:ClientID InvoiceDate1 2012-01-012 2012-01-013 2012-01-01Can you tell me what query I will need to write to achieve this.Thanks |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2014-10-13 : 12:08:36
|
This sure looks like a homework question, but I'm confused by your number of posts.select ClientID, MIN(InvoiceDate) as InvoiceDatefrom yourtablegroup by ClientIDTara KizerSQL Server MVP since 2007http://weblogs.sqlteam.com/tarad/ |
|
|
|
|
|