title: Exclude a duplicate record from a view based on condtions and keep 1 - SQL Server 2012
body: <p>I have three joined tables <code>Student</code>, <code>StudentTransportOrder</code> and <code>Transport</code> in SQL Server 2012.</p>
  
  <p>I have created a <code>StudentActivity</code> view for this.</p>
  
  <p>In the <code>StudentTransportOrder</code> table, each student record has a unique <code>TransportOrderID</code>.</p>
  
  <p>When transport is ordered, <code>VehicleID</code> this is recorded into the <code>StudentTransportOrder</code> table.</p>
  
  <p>Unfortunately the same <code>VehicleID</code> has been entered for the same date and time for a student records.</p>
  
  <p>The <code>StudentActivity</code> view already returns records based on where conditions, but I also need to remove the duplicate records, preferably keep the records where if a student has used transport on the same date and time, that only one distinct VehicleID is returned and preferably the where the transport type is TransportVehicle = Car</p>
  
  <p>How can I amend the view , without deleting records from the main tables, also bring back records even if no transport has been ordered </p>
  
  <p>Please help</p>