Help needed with TSQL statement
am 01.04.2008 23:34:51 von Greg HinesHi all,
I have a booking table that records changes to bookings to give an audit
trail.
Table1
ID - is an Identity column.
BookingID - is a varchar column containing the booking id of each booking.
Comment - is a varchar column containing details of the booking changes.
dtTime - a datetime column containing the date and time of the booking
change.
eg:
ID BookingID Comment dtTime
1 30 Initial booking
2004-07-08 13:36:23.363
4 31 Initial booking
2004-07-08 13:37:23.363
5 30 First change
2004-07-08 13:38:23.363
9 31 First change
2004-07-08 13:39:23.363
11 30 Second change
2004-07-08 13:40:23.363
Note there has been 2 changes to the intial booking for bookingID 30, and
one change for bookingID 31.
What I want is an SQL SELECT statement that will give me all the ID's for
the initial booking. In this example 1 and 4 should be the only results
that the statement will return.
Any help appreciated and TIA
Greg