.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
Kaviya Balasubramanian
Sgraph Infotech
Imran Ghani
Post New Web Links

SQL

Posted By:      Posted Date: September 20, 2010    Points: 0   Category :ASP.Net
 

Hi ,


Building a web site in C# and using sql server ...

Its a web site where devices can be loaned to people and once they use it they return it back.

I have a Device table which has the fields DeviceID,DeviceName,Office,SentDate, ReturnDate. The composite primary key is DeviceID and SentDate.


Eg of 4 records=> DeviceID:DeviceName:Office:SentDate:ReturnDate

Records

1:ABC:Office1:7/22/2010:7/29/2010

2:XYZ:Office2:7/23/2010:7/30/2010

3:LMN:Office1:8/20/2010:7/23/2010

1:ABC:Office3:8/12/2010:7/19/2010

2:XYZ:Office2:8/23/2010:


If the device is not returned the returnDate could be either null or blank as inrecord 5.


I need to extract all the devices that are there in the table but only 1 record for each device with the latest record, so the result set would be like this


Result Set

3:LMN:Office1:8/20/2010:7/23/2010

1:ABC:Office3:8/12/2010:7/19/2010

2:XYZ:Office2:8/23/2010:


When I tried a groupby, it says cannot aggragate DeviceName etc...


Can some body provide me the sql query to achieve this.


Thanking in advance..








View Complete Post


More Related Resource Links

Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend