Loading
  1. SELECT DISTINCT
  2.                          sampling_soil_order.id, sampling_soil_order.group_id, sampling_soil_order.date_added, sampling_soil_order.sampling_status_id, FIELDS.field_id, FIELDS.field_name,
  3.                          farms.id_farm, farms.farm_name, trading_name.id_trading_name, trading_name.trading_name, access.access_id, access.access_name AS TAG,
  4.                          sampling_order_status.status, staff.id_staff
  5. FROM            sampling_soil_order INNER JOIN
  6.                          FIELDS ON sampling_soil_order.field_id = FIELDS.field_id INNER JOIN
  7.                          farms ON FIELDS.farm_id = farms.id_farm INNER JOIN
  8.                          trading_name ON farms.trading_id = trading_name.id_trading_name INNER JOIN
  9.                          staff ON sampling_soil_order.staff_id = staff.id_staff LEFT OUTER JOIN
  10.                          access ON staff.company_id = access.id INNER JOIN
  11.                          sampling_order_status ON sampling_soil_order.sampling_status_id = sampling_order_status.id INNER JOIN
  12.                          access_trading ON trading_name.id_trading_name = access_trading.trading_id
  13. WHERE        (sampling_soil_order.deleted = 0) AND (access_trading.access_id = @companyid) AND (sampling_order_status.visible_on_portal = 1)
  14. GROUP BY sampling_soil_order.group_id
  15. ORDER BY sampling_soil_order.id DESC

Comments