-- Select 3 Get Objects_tbl Data
SELECT *
 from Objects_tbl WITH (nolock)
WHERE Objects_tbl.Id in
( -- Select 2 = get ObjectId
  select Objects_Ir_Rel_tbl.ObjectId
  from Objects_Ir_Rel_tbl WITH (nolock)
  WHERE Objects_Ir_Rel_tbl.IrId in
    ( -- Select 1 = get IrId
      SELECT TOP 2
        Objects_Ir_Rel_tbl.IrId
      FROM
        Objects_tbl WITH (nolock)
        INNER JOIN Objects_Ir_Rel_tbl ON (Objects_tbl.Id = Objects_Ir_Rel_tbl.ObjectId)
      WHERE
        Objects_tbl.ObjectClass = 'DS' AND
        Objects_tbl.ProcStateColRf = 'N' AND
        Objects_tbl.ObjectFromSiteID = 'tceng' AND
        Objects_tbl.ObjectUgMaster_Type = 'SP' AND
        Objects_tbl.ObjectType = 'UGPART'
      ORDER BY
        Objects_tbl.ObjectLastModDate DESC
    )
)
