Question

  Asked: Feb 20 2008   6:31 AM GMT
  Asked by: Binu.emiliya


How to make a single row in SQL


Query, SQL queries, SQL

Dear all,
Please help me I am not good in sql queries.
I have a view like this.

SNo Employee title Cdate IN TIME OUT TIME
258 john accountant 27/01/2008 7:28:12
258 john accountant 27/01/2008 7:28:30
258 john accountant 27/01/2008 16:03:42
258 john accountant 27/01/2008 16:03:48
258 john accountant 28/01/2008 7:36:42
258 john accountant 28/01/2008 7:36:51
258 john accountant 28/01/2008 16:05:24
258 john accountant 28/01/2008 16:05:30

Now i need to solve the following problem
to find the min(time) for a particular date
and max of the same date
and as a single raw for th particular date

as below

staffNo Employee title Cdate IN TIME OUT TIME
258 john accountant 27/01/2008 7:28:12 16:03:48

Subscribe to Alerts! Get questions and answers delivered to your Inbox.


E-mail me updates on this question



   SUBSCRIBE

hidden modal window

Answer Wiki (Improve, edit or add to this answer)


 RATE THIS ANSWER
0
Click to Vote:
  •   0
  •  0



That's done by putting a MIN() and MAX() in the SELECT statement.

SELECT SNo, Employee, Title, cdate, MIN(TimeColumn) MinTime, MAX(TimeColumn) MaxTime
FROM YourView
GROUP BY SNo, Employee, Title, cdate
  • AddThis Social Bookmark Button

Browse more Questions and Answers on Development and SQL Server.

Looking for relevant Development Whitepapers? Visit the SearchSQLServer.com Research Library.


Discuss This Answer


You must be logged-in to discuss a question. Log-in/Register

Mrdenny  |   Feb 20 2008  8:01AM GMT

Check out my SQL Server blog “SQL Server with Mr Denny” for more SQL Server information.