Click here to Skip to main content
15,907,183 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello All,

I have a scenario in which i have a column "Time" in a table, noiw i have to find the max and min value of time according to date for eachy employee in 2 other colmns, i am trying to do it using RowNumber() function...

Is it right or any other suggestions...??
Posted
Comments
Thanks7872 27-Aug-13 1:48am    
What you want from us? Answer you with what? Question is not cleat at first place then no suggestions can be made.
abhishekagrwl25 27-Aug-13 2:00am    
RowID EmployeeID Time Access_Date
2 9007 14:45:43 2011/09/20
3 9007 14:49:50 2011/09/20
4 9007 14:45:43 2011/09/20
5 9007 14:49:50 2011/09/20

Above is the table from which i want to make a new table with column named(EmployeeID, In_Time, Out_Time,Access_Date) in which In_Time will be the Min time for respective date and Out_Time will be the max time for date for particular employee...

i need this for creating a report in ASP.Net...

Try:
SQL
SELECT employee, MAX(myDateColumn) AS MaxDate, MIN(myDateColumn) AS MinDate FROM MyTable GROUP BY employee
 
Share this answer
 
Hi,

This :

SQL
SELECT [RowID], [EmployeeID], [Access_Date], MIN([Time]) AS MinTime, MAX([Time]) AS MaxTime FROM [TableName] GROUP BY [EmployeeID], [Access_Date]


should do it. I included the [Access_Date] column to get min and max times grouped by dates.
Hope this helps.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900