sql - Distinct room types -


How do I change SQL to give me the different room type? I only need one in roomtype_id every room_id . If that makes any sense? In fact if there are 3 different types of 5 rooms, then only 3 records should be returned.

An example of the current SQL ...

  SELECT dbo.rooms.room_id, Dbo.roomtypes.name, dbo.rooms.roomtype_id FROM dbo.rooms INNER JOIN Dbo.rooms.roomtype_id = dbo.roomtypes.roomtype_id WHERE (dbo.rooms.room_id not on dbo.roomtypes (select room from dbo.booking)) and (dbo.rooms.roomtype_id> = 4)    

one way group BY :

  SELECT MAX (dbo.rooms.room_id), max (dbo.roomtypes.name), dbo.rooms.roomtype_id FROM dbo.rooms INNER JOIN dbo .roomtypes ON dbo.rooms.roomtype_id = dbo.roomtypes.roomtype_id WHERE ( Dbo.rooms.room_id (select room_id from dbo.booking)) and (dbo.rooms.roomtype_id> = 4) GROUP BY dbo.rooms. Roomtype_id    

Comments