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


Top 5 Contributors of the Month
Easy Web
Imran Ghani
Post New Web Links

top row in a select

Posted By:      Posted Date: October 19, 2010    Points: 0   Category :Sql Server
 

Hello all, Please help me with this sql query. I have 2 tables. Employees and Sessions
Employees
EmpNid Name
01 Alex
02 Andy

Sessions
SessionNid EmpNid LoginTime LogoutTime
001 01 2010-10-19 12:40:23.520 2010-10-19 12:40:33.190
002 01 2010-10-19 09:23:18.850 2010-10-19 09:23:24.693
003 01 2010-10-19 09:20:05.030 2010-10-19 09:20:16.653
004 02 2010-10-19 13:32:24.367 2010-10-19 13:32:31.103
005 02 2010-10-19 12:53:28.257 2010-10-19 12:53:35.037
006 02 2010-10-19 12:53:14.240 2010-10-19 12:53:17.350
007 02 2010-10-19 12:47:23.753 2010-10-19 12:47:34.520

supposed today's day is 10/19/2010

Trying this query will show
select distinct s.empnid,e.name, s.logintime, s.logouttime
from employees e, Sessions S
where e.empnid=s.empnid and s.logintime>'10/19/2010'
order by e.name, s.logintime desc

Name LoginTime LogoutTime
Alex 2010-10-19 12:40:23.520 2010-10-19 12:40:33.190
Alex 2010-10-19 09:23:18.850 2010-10-19 09:23:24.693
Alex 2010-10-19 09:20:05.030 2010-10-19 09:20:16.653
Andy 2010-10-19 13:32:24.367 2010-10-19 13:32:31.103
Andy 2010-10-19 12:53:28.257 2010-10-19 12:53:35.037
Andy 2010-10-19 12:53:14.240 2010-10-19 12:53:17.350
Andy 2010-10-19 12:47:2


View Complete Post


More Related Resource Links

AJAX GridView Checkbox Select All in ASP.Net

  
In the previous article GridView Select Multiple Rows you learnt the multiple row selection in GridView control. Here you will get the C# code sample to select all the gridview rows using single checkbox server control. You can highlight the selected rows with different color and Font state Bold. If you want to use the selection values on different ASP.Net

Select value in gridview

  

Hi, I am new to gridview. I want to make a gridview. Its row when selected should direct me to a specific .aspx page.Each row should direct to a different page. Should I use querystrings for this? Please suggest. Regards, ap.


The XML Files: XSLT Keys, Select vs. Match, Conflict Resolution, and More

  

This month Aaron Skonnard covers how keys work in XSLT, XSLT match and select attributes, SelectNodes order, finding