Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set up a condition in a query

Status
Not open for further replies.

inarobis

IS-IT--Management
Joined
Apr 3, 2006
Messages
71
Location
CH
Hello guys,

I have a question about a sql query so I have these 5 tables

there are 5 tables

Room, RommRent, DBSource, RoomType, RoomRealCode

SELECT Room.idCode, RoomRent.Label, MAX(chambrerent.[TimeStamp]), RoomRent.TreeID
FROM RoomRent INNER JOIN
DBsource ON RoomRent.DBSource_ID = DBSource.DBSource_ID RIGHT OUTER JOIN Room LEFT OUTER JOIN
RoomRealCode ON RoomRealCode.RoomReal_ID = Room.RoomReal_ID ON DBSource.DBSource_ID = T_RoomRealCode.DBSource_ID
GROUP BY Room.idCode, DBSource.sourceName, RoomRent.Label, RoomRent.[TimeStamp], DBSource.sourceName,
RoomRent.RoomType, RoomRent.TreeID
HAVING (Room.idCode = 'Royal3D')
ORDER BY MAX(RoomRent.[TimeStamp]) DESC

IDCODE LABEL TIMESTAMP TREEID
Royal3D Suite 2006-05-30 12:21:17.457 242827
Royal3D 3RM 2006-05-30 12:21:17.457 242827
Royal3D 3FM 2006-05-30 12:21:17.457 242827
Royal3D Suite 2006-04-25 14:40:05.263 204750
Royal3D 3FM 2006-04-25 14:40:05.263 204750
Royal3D Simple 2006-04-11 14:18:03.000 30000

I would like to obtain, the max of timestamp and with the same TREEID
IDCODE LABEL TIMESTAMP TREEID
Royal3D Suite 2006-05-30 12:21:17.457 242827
Royal3D 3RM 2006-05-30 12:21:17.457 242827
Royal3D 3FM 2006-05-30 12:21:17.457 242827


How can I send up this condition?

Ina

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top