Table of Contents

Proposed Work Order Task

Table

Database Table Entity On Key 5 Conversions On Key 5 Tables Other Entities stored in same Table
Transaction wm.proposed_work_order_task Proposed Work Order Task

Columns

Property Db Table Db Column Db DataType Nullable Primary Key Joins
CreatedByUserId wm.proposed_work_order_task created_by_user_id bigint False
CreatedByUserCode uam.user code character varying(50) False wm.proposed_work_order_task.created_by_user_id = uam.user.user_id
CreatedByUserFullName uam.user full_name character varying(200) False wm.proposed_work_order_task.created_by_user_id = uam.user.user_id
CreatedOn wm.proposed_work_order_task created_on timestamp without time zone False
ModifiedByUserId wm.proposed_work_order_task modified_by_user_id bigint False
ModifiedByUserCode uam.user code character varying(50) False wm.proposed_work_order_task.modified_by_user_id = uam.user.user_id
ModifiedByUserFullName uam.user full_name character varying(200) False wm.proposed_work_order_task.modified_by_user_id = uam.user.user_id
ModifiedOn wm.proposed_work_order_task modified_on timestamp without time zone False
Version wm.proposed_work_order_task version integer False
PermissionTreeId wm.proposed_work_order_task permission_tree_id bigint False
PermissionTreeCode uam.permission_tree code text False wm.proposed_work_order_task.permission_tree_id = uam.permission_tree.permission_tree_id
PermissionTreeDescription uam.permission_tree description text True wm.proposed_work_order_task.permission_tree_id = uam.permission_tree.permission_tree_id
SiteId wm.proposed_work_order_task site_id bigint True
SiteCode gen.site code character varying False wm.proposed_work_order_task.site_id = gen.site.site_id
SiteDescription gen.site description character varying False wm.proposed_work_order_task.site_id = gen.site.site_id
Id wm.proposed_work_order_task proposed_work_order_task_id bigint False True
AlternativeDescription wm.proposed_work_order_task alternative_description character varying(255) False
AssetId wm.proposed_work_order_task asset_id bigint False
AssetCode ampc.asset code character varying(50) False wm.proposed_work_order_task.asset_id = ampc.asset.asset_id
AssetTaskId wm.proposed_work_order_task asset_task_id bigint False
AssetTaskCode ampc.asset_task code character varying(50) False wm.proposed_work_order_task.asset_task_id = ampc.asset_task.asset_task_id
AssetTaskDescription ampc.asset_task description character varying(255) False wm.proposed_work_order_task.asset_task_id = ampc.asset_task.asset_task_id
AssetTaskInspectionType ampc.asset_task inspection_type ampc.inspection_type True wm.proposed_work_order_task.asset_task_id = ampc.asset_task.asset_task_id
DefaultIntervalId wm.proposed_work_order_task default_interval_id bigint True
DefaultIntervalCode ampc.task_interval code character varying(50) False wm.proposed_work_order_task.default_interval_id = ampc.task_interval.task_interval_id
DefaultIntervalDescription ampc.task_interval description character varying(100) True wm.proposed_work_order_task.default_interval_id = ampc.task_interval.task_interval_id
DefaultIntervalTaskIntervalTypeId ampc.task_interval_type task_interval_type_id bigint False True wm.proposed_work_order_task.default_interval_id = ampc.task_interval.task_interval_id Then
ampc.task_interval.task_interval_type_id = ampc.task_interval_type.task_interval_type_id
Description wm.proposed_work_order_task description character varying(255) False
DueDate wm.proposed_work_order_task due_date timestamp without time zone False
DueReading wm.proposed_work_order_task due_reading numeric(19,4) True
EventId wm.proposed_work_order_task event_id bigint True
EventCode ampc.event code character varying(50) False wm.proposed_work_order_task.event_id = ampc.event.event_id
EventDescription ampc.event description character varying(100) False wm.proposed_work_order_task.event_id = ampc.event.event_id
FailedReason wm.proposed_work_order_task failed_reason character varying(100) True
IntervalTypeId wm.proposed_work_order_task interval_type_id bigint True
IntervalTypeCode ampc.task_interval_type code character varying(50) False wm.proposed_work_order_task.interval_type_id = ampc.task_interval_type.task_interval_type_id
IntervalTypeDescription ampc.task_interval_type description character varying(100) False wm.proposed_work_order_task.interval_type_id = ampc.task_interval_type.task_interval_type_id
IntervalTypeSchedulingKind ampc.task_interval_type scheduling_kind ampc.task_scheduling_kind False wm.proposed_work_order_task.interval_type_id = ampc.task_interval_type.task_interval_type_id
IsStatutory wm.proposed_work_order_task is_statutory boolean True
IsSuppressed wm.proposed_work_order_task is_suppressed boolean True
LastDoneDate wm.proposed_work_order_task last_done_date timestamp without time zone True
LastDoneReading wm.proposed_work_order_task last_done_reading numeric(19,4) True
MachineState wm.proposed_work_order_task machine_state ampc.machine_state True
MeterId wm.proposed_work_order_task meter_id bigint True
MeterCode aom.meter code character varying(50) False wm.proposed_work_order_task.meter_id = aom.meter.meter_id
MeterLastReading aom.meter last_reading numeric(19,4) True wm.proposed_work_order_task.meter_id = aom.meter.meter_id
MeterAverageDailyRate aom.meter average_daily_rate numeric(19,4) False wm.proposed_work_order_task.meter_id = aom.meter.meter_id
MeterCumulativeReading aom.meter cumulative_reading numeric(19,4) True wm.proposed_work_order_task.meter_id = aom.meter.meter_id
MeterLastReadOn aom.meter last_read_on timestamp without time zone True wm.proposed_work_order_task.meter_id = aom.meter.meter_id
MeterNotes aom.meter notes text True wm.proposed_work_order_task.meter_id = aom.meter.meter_id
MeterDescription aom.meter description character varying(100) False wm.proposed_work_order_task.meter_id = aom.meter.meter_id
MonitoringPointId wm.proposed_work_order_task monitoring_point_id bigint True
MonitoringPointCode ahm.monitoring_point code character varying(50) False wm.proposed_work_order_task.monitoring_point_id = ahm.monitoring_point.monitoring_point_id
MonitoringPointDescription ahm.monitoring_point description character varying(100) False wm.proposed_work_order_task.monitoring_point_id = ahm.monitoring_point.monitoring_point_id
MonitoringPointIsCalculated ahm.monitoring_point is_calculated boolean False wm.proposed_work_order_task.monitoring_point_id = ahm.monitoring_point.monitoring_point_id
MonitoringPointMonitoringPointTypeId ahm.monitoring_point_type monitoring_point_type_id bigint False True wm.proposed_work_order_task.monitoring_point_id = ahm.monitoring_point.monitoring_point_id Then
ahm.monitoring_point.monitoring_point_type_id = ahm.monitoring_point_type.monitoring_point_type_id
MonitoringPointMonitoringPointTypeCode ahm.monitoring_point_type code character varying(50) False wm.proposed_work_order_task.monitoring_point_id = ahm.monitoring_point.monitoring_point_id Then
ahm.monitoring_point.monitoring_point_type_id = ahm.monitoring_point_type.monitoring_point_type_id
MonitoringPointMonitoringPointTypeDescription ahm.monitoring_point_type description character varying(100) False wm.proposed_work_order_task.monitoring_point_id = ahm.monitoring_point.monitoring_point_id Then
ahm.monitoring_point.monitoring_point_type_id = ahm.monitoring_point_type.monitoring_point_type_id
MotionType wm.proposed_work_order_task motion_type ampc.motion_type True
ProposedWorkOrderId wm.proposed_work_order_task proposed_work_order_id bigint True
ProposedWorkOrderDescription wm.proposed_work_order description character varying(255) False wm.proposed_work_order_task.proposed_work_order_id = wm.proposed_work_order.proposed_work_order_id
ResponsibleSectionId wm.proposed_work_order_task responsible_section_id bigint True
ResponsibleSectionCode res.section code character varying(50) False wm.proposed_work_order_task.responsible_section_id = res.section.section_id
ResponsibleSectionDescription res.section description character varying(100) False wm.proposed_work_order_task.responsible_section_id = res.section.section_id
ResponsibleStaffMemberResourceId wm.proposed_work_order_task responsible_staff_member_resource_id bigint True
ResponsibleStaffMemberResourceCode res.resource code character varying(50) False wm.proposed_work_order_task.responsible_staff_member_resource_id = res.resource.resource_id
ResponsibleStaffMemberResourceDescription res.resource description character varying(100) True wm.proposed_work_order_task.responsible_staff_member_resource_id = res.resource.resource_id
ResponsibleStaffMemberResourceResourceType res.resource resource_type res.resource_type False wm.proposed_work_order_task.responsible_staff_member_resource_id = res.resource.resource_id
ResponsibleStaffMemberResourceContactDetailId res.resource_contact_detail resource_contact_detail_id bigint False True
ResponsibleStaffMemberResourceContactDetailFirstName res.resource_contact_detail first_name character varying(100) True
ResponsibleStaffMemberResourceContactDetailLastName res.resource_contact_detail last_name character varying(100) True
ResponsibleStaffMemberResourceContactDetailDepartment res.resource_contact_detail department character varying(100) True
ResponsibleStaffMemberResourceContactDetailJobTitle res.resource_contact_detail job_title character varying(100) True
ResponsibleStaffMemberResourceSiteId gen.site site_id bigint False True wm.proposed_work_order_task.responsible_staff_member_resource_id = res.resource.resource_id Then
res.resource.site_id = gen.site.site_id
ResponsibleStaffMemberResourceSiteCode gen.site code character varying False wm.proposed_work_order_task.responsible_staff_member_resource_id = res.resource.resource_id Then
res.resource.site_id = gen.site.site_id
ResponsibleStaffMemberResourceSiteDescription gen.site description character varying False wm.proposed_work_order_task.responsible_staff_member_resource_id = res.resource.resource_id Then
res.resource.site_id = gen.site.site_id
ResponsibleTradeId wm.proposed_work_order_task responsible_trade_id bigint True
ResponsibleTradeCode res.trade code character varying(50) False wm.proposed_work_order_task.responsible_trade_id = res.trade.trade_id
ResponsibleTradeDescription res.trade description character varying(100) False wm.proposed_work_order_task.responsible_trade_id = res.trade.trade_id
SchedulingKind wm.proposed_work_order_task scheduling_kind ampc.task_scheduling_kind False
SchedulingMethod wm.proposed_work_order_task scheduling_method ampc.task_scheduling_method True
SuppressedBy wm.proposed_work_order_task suppressed_by wm.due_task_suppressed_by True
TotalDowntime wm.proposed_work_order_task total_downtime interval True
TotalDuration wm.proposed_work_order_task total_duration interval True
TypeOfWorkId wm.proposed_work_order_task type_of_work_id bigint True
TypeOfWorkCode ampc.type_of_work code character varying(50) False wm.proposed_work_order_task.type_of_work_id = ampc.type_of_work.type_of_work_id
TypeOfWorkDescription ampc.type_of_work description character varying(100) False wm.proposed_work_order_task.type_of_work_id = ampc.type_of_work.type_of_work_id
TypeOfWorkWorkType ampc.type_of_work work_type ampc.work_type True wm.proposed_work_order_task.type_of_work_id = ampc.type_of_work.type_of_work_id
TypeOfWorkWorkClass ampc.type_of_work work_class ampc.work_class False wm.proposed_work_order_task.type_of_work_id = ampc.type_of_work.type_of_work_id

Enumerations

Mapping 1

Property Property Type Db Column Db Column Type Db Column Values
AssetTaskInspectionType InspectionType inspection_type ampc.inspection_type PassOrFail
ManualMonitoring
AutomaticMonitoring
ManualAndAutomaticMonitoring
ManualReadingOnly

Mapping 2

Property Property Type Db Column Db Column Type Db Column Values
IntervalTypeSchedulingKind TaskSchedulingKind scheduling_kind ampc.task_scheduling_kind AdHoc
Calendar
Event
Usage

Mapping 3

Property Property Type Db Column Db Column Type Db Column Values
MachineState MachineState machine_state ampc.machine_state RunningOrNotRunning
OnlyNotRunning
OnlyRunning

Mapping 4

Property Property Type Db Column Db Column Type Db Column Values
MotionType MotionType motion_type ampc.motion_type StationaryOrInMotion
OnlyWhenStationary
OnlyWhenInMotion

Mapping 5

Property Property Type Db Column Db Column Type Db Column Values
ResponsibleStaffMemberResourceResourceType ResourceType resource_type res.resource_type StaffMember
SpecialResource
Contact

Mapping 6

Property Property Type Db Column Db Column Type Db Column Values
SchedulingKind TaskSchedulingKind scheduling_kind ampc.task_scheduling_kind AdHoc
Calendar
Event
Usage

Mapping 7

Property Property Type Db Column Db Column Type Db Column Values
SchedulingMethod TaskSchedulingMethod scheduling_method ampc.task_scheduling_method LastScheduled
LastDone

Mapping 8

Property Property Type Db Column Db Column Type Db Column Values
SuppressedBy SuppressedBy suppressed_by wm.due_task_suppressed_by NotSuppressed
SuppressorTask
MachineIsRunning
MachineIsNotRunning
Duplicate
LastDoneTaskOnIncompleteWorkOrder
LastDoneTaskOnPreviousProposedWorkOrder
IncompleteConfiguration

Mapping 9

Property Property Type Db Column Db Column Type Db Column Values
TypeOfWorkWorkType WorkType work_type ampc.work_type Breakdown
Reactive
AdHoc
Inspect
FollowUp

Mapping 10

Property Property Type Db Column Db Column Type Db Column Values
TypeOfWorkWorkClass WorkClass work_class ampc.work_class NonTactical
Tactical
OperationalWork
ContinuousImprovement
AdministrativeWork

Queries

The list of example Proposed Work Order Task queries can be interpreted using the following legend:

Legend Description
Primary Table Alias The alias for the wm.proposed_work_order_task table in the query
Include References Include (true) or exclude (false) all lookup table joins in the query
Include Permissions Include (true) or exclude (false) the permission table join in the query to enforce or skip row-level security based on the permissions for the user

Query 1

Primary Table Alias Include References Include Permissions
_pwot False False
SELECT
    _pwot.created_by_user_id AS "CreatedByUserId",
    _pwot.created_on AS "CreatedOn",
    _pwot.modified_by_user_id AS "ModifiedByUserId",
    _pwot.modified_on AS "ModifiedOn",
    _pwot.version AS "Version",
    _pwot.permission_tree_id AS "PermissionTreeId",
    _pwot.site_id AS "SiteId",
    _pwot.proposed_work_order_task_id AS "Id",
    _pwot.alternative_description AS "AlternativeDescription",
    _pwot.asset_id AS "AssetId",
    _pwot.asset_task_id AS "AssetTaskId",
    _pwot.default_interval_id AS "DefaultIntervalId",
    _pwot.description AS "Description",
    _pwot.due_date AS "DueDate",
    _pwot.due_reading AS "DueReading",
    _pwot.event_id AS "EventId",
    _pwot.failed_reason AS "FailedReason",
    _pwot.interval_type_id AS "IntervalTypeId",
    _pwot.is_statutory AS "IsStatutory",
    _pwot.is_suppressed AS "IsSuppressed",
    _pwot.last_done_date AS "LastDoneDate",
    _pwot.last_done_reading AS "LastDoneReading",
    _pwot.machine_state AS "MachineState",
    _pwot.meter_id AS "MeterId",
    _pwot.monitoring_point_id AS "MonitoringPointId",
    _pwot.motion_type AS "MotionType",
    _pwot.proposed_work_order_id AS "ProposedWorkOrderId",
    _pwot.responsible_section_id AS "ResponsibleSectionId",
    _pwot.responsible_staff_member_resource_id AS "ResponsibleStaffMemberResourceId",
    _pwot.responsible_trade_id AS "ResponsibleTradeId",
    _pwot.scheduling_kind AS "SchedulingKind",
    _pwot.scheduling_method AS "SchedulingMethod",
    _pwot.suppressed_by AS "SuppressedBy",
    _pwot.total_downtime AS "TotalDowntime",
    _pwot.total_duration AS "TotalDuration",
    _pwot.type_of_work_id AS "TypeOfWorkId"
FROM
    wm.proposed_work_order_task _pwot


Query 2

Primary Table Alias Include References Include Permissions
_pwot True False
SELECT
    _u.user_id AS "CreatedByUserId",
    _u.code AS "CreatedByUserCode",
    _u.full_name AS "CreatedByUserFullName",
    _pwot.created_on AS "CreatedOn",
    _u1.user_id AS "ModifiedByUserId",
    _u1.code AS "ModifiedByUserCode",
    _u1.full_name AS "ModifiedByUserFullName",
    _pwot.modified_on AS "ModifiedOn",
    _pwot.version AS "Version",
    _pt.permission_tree_id AS "PermissionTreeId",
    _pt.code AS "PermissionTreeCode",
    _pt.description AS "PermissionTreeDescription",
    _s.site_id AS "SiteId",
    _s.code AS "SiteCode",
    _s.description AS "SiteDescription",
    _pwot.proposed_work_order_task_id AS "Id",
    _pwot.alternative_description AS "AlternativeDescription",
    _a.asset_id AS "AssetId",
    _a.code AS "AssetCode",
    _at.asset_task_id AS "AssetTaskId",
    _at.code AS "AssetTaskCode",
    _at.description AS "AssetTaskDescription",
    _at.inspection_type AS "AssetTaskInspectionType",
    _ti.task_interval_id AS "DefaultIntervalId",
    _ti.code AS "DefaultIntervalCode",
    _ti.description AS "DefaultIntervalDescription",
    _ti.task_interval_type_id AS "DefaultIntervalTaskIntervalType",
    _tit.task_interval_type_id AS "DefaultIntervalTaskIntervalTypeId",
    _pwot.description AS "Description",
    _pwot.due_date AS "DueDate",
    _pwot.due_reading AS "DueReading",
    _e.event_id AS "EventId",
    _e.code AS "EventCode",
    _e.description AS "EventDescription",
    _pwot.failed_reason AS "FailedReason",
    _tit1.task_interval_type_id AS "IntervalTypeId",
    _tit1.code AS "IntervalTypeCode",
    _tit1.description AS "IntervalTypeDescription",
    _tit1.scheduling_kind AS "IntervalTypeSchedulingKind",
    _pwot.is_statutory AS "IsStatutory",
    _pwot.is_suppressed AS "IsSuppressed",
    _pwot.last_done_date AS "LastDoneDate",
    _pwot.last_done_reading AS "LastDoneReading",
    _pwot.machine_state AS "MachineState",
    _m.meter_id AS "MeterId",
    _m.code AS "MeterCode",
    _m.last_reading AS "MeterLastReading",
    _m.average_daily_rate AS "MeterAverageDailyRate",
    _m.cumulative_reading AS "MeterCumulativeReading",
    _m.last_read_on AS "MeterLastReadOn",
    _m.notes AS "MeterNotes",
    _m.description AS "MeterDescription",
    _mp.monitoring_point_id AS "MonitoringPointId",
    _mp.code AS "MonitoringPointCode",
    _mp.description AS "MonitoringPointDescription",
    _mp.is_calculated AS "MonitoringPointIsCalculated",
    _mp.monitoring_point_type_id AS "MonitoringPointMonitoringPointType",
    _mpt.monitoring_point_type_id AS "MonitoringPointMonitoringPointTypeId",
    _mpt.code AS "MonitoringPointMonitoringPointTypeCode",
    _mpt.description AS "MonitoringPointMonitoringPointTypeDescription",
    _pwot.motion_type AS "MotionType",
    _pwo.proposed_work_order_id AS "ProposedWorkOrderId",
    _pwo.description AS "ProposedWorkOrderDescription",
    _s1.section_id AS "ResponsibleSectionId",
    _s1.code AS "ResponsibleSectionCode",
    _s1.description AS "ResponsibleSectionDescription",
    _r.resource_id AS "ResponsibleStaffMemberResourceId",
    _r.code AS "ResponsibleStaffMemberResourceCode",
    _r.description AS "ResponsibleStaffMemberResourceDescription",
    _r.resource_type AS "ResponsibleStaffMemberResourceResourceType",
    _rcd.resource_contact_detail_id AS "ResponsibleStaffMemberResourceContactDetailId",
    _rcd.first_name AS "ResponsibleStaffMemberResourceContactDetailFirstName",
    _rcd.last_name AS "ResponsibleStaffMemberResourceContactDetailLastName",
    _rcd.department AS "ResponsibleStaffMemberResourceContactDetailDepartment",
    _rcd.job_title AS "ResponsibleStaffMemberResourceContactDetailJobTitle",
    _r.site_id AS "ResponsibleStaffMemberResourceSite",
    _s2.site_id AS "ResponsibleStaffMemberResourceSiteId",
    _s2.code AS "ResponsibleStaffMemberResourceSiteCode",
    _s2.description AS "ResponsibleStaffMemberResourceSiteDescription",
    _t.trade_id AS "ResponsibleTradeId",
    _t.code AS "ResponsibleTradeCode",
    _t.description AS "ResponsibleTradeDescription",
    _pwot.scheduling_kind AS "SchedulingKind",
    _pwot.scheduling_method AS "SchedulingMethod",
    _pwot.suppressed_by AS "SuppressedBy",
    _pwot.total_downtime AS "TotalDowntime",
    _pwot.total_duration AS "TotalDuration",
    _tow.type_of_work_id AS "TypeOfWorkId",
    _tow.code AS "TypeOfWorkCode",
    _tow.description AS "TypeOfWorkDescription",
    _tow.work_type AS "TypeOfWorkWorkType",
    _tow.work_class AS "TypeOfWorkWorkClass"
FROM
    wm.proposed_work_order_task _pwot
    JOIN uam.user _u ON _pwot.created_by_user_id = _u.user_id
    JOIN uam.user _u1 ON _pwot.modified_by_user_id = _u1.user_id
    JOIN uam.permission_tree _pt ON _pwot.permission_tree_id = _pt.permission_tree_id
    LEFT JOIN gen.site _s ON _pwot.site_id = _s.site_id
    JOIN ampc.asset _a ON _pwot.asset_id = _a.asset_id
    JOIN ampc.asset_task _at ON _pwot.asset_task_id = _at.asset_task_id
    LEFT JOIN ampc.task_interval _ti ON _pwot.default_interval_id = _ti.task_interval_id
    LEFT JOIN ampc.task_interval_type _tit ON _ti.task_interval_type_id = _tit.task_interval_type_id
    LEFT JOIN ampc.event _e ON _pwot.event_id = _e.event_id
    LEFT JOIN ampc.task_interval_type _tit1 ON _pwot.interval_type_id = _tit1.task_interval_type_id
    LEFT JOIN aom.meter _m ON _pwot.meter_id = _m.meter_id
    LEFT JOIN ahm.monitoring_point _mp ON _pwot.monitoring_point_id = _mp.monitoring_point_id
    LEFT JOIN ahm.monitoring_point_type _mpt ON _mp.monitoring_point_type_id = _mpt.monitoring_point_type_id
    JOIN wm.proposed_work_order _pwo ON _pwot.proposed_work_order_id = _pwo.proposed_work_order_id
    LEFT JOIN res.section _s1 ON _pwot.responsible_section_id = _s1.section_id
    LEFT JOIN res.resource _r ON _pwot.responsible_staff_member_resource_id = _r.resource_id
    LEFT JOIN res.resource_contact_detail _rcd ON _r.resource_id = _rcd.resource_contact_detail_id
    LEFT JOIN gen.site _s2 ON _r.site_id = _s2.site_id
    LEFT JOIN res.trade _t ON _pwot.responsible_trade_id = _t.trade_id
    JOIN ampc.type_of_work _tow ON _pwot.type_of_work_id = _tow.type_of_work_id


Query 3

Primary Table Alias Include References Include Permissions
_pwot False True
Parameter Name Data Type Value
@permission_user_id Bigint 500000000000
@permission_id Bigint 100120100
WITH permission_tree_ids AS
(
    SELECT DISTINCT unnest(psd.permission_tree_ids) AS permission_tree_id FROM uam.user_permission up JOIN uam.permission_set_data psd ON up.permission_set_id = psd.permission_set_id WHERE up.user_id = @permission_user_id AND up.permission_id = @permission_id
)
SELECT
    _pwot.created_by_user_id AS "CreatedByUserId",
    _pwot.created_on AS "CreatedOn",
    _pwot.modified_by_user_id AS "ModifiedByUserId",
    _pwot.modified_on AS "ModifiedOn",
    _pwot.version AS "Version",
    _pwot.permission_tree_id AS "PermissionTreeId",
    _pwot.site_id AS "SiteId",
    _pwot.proposed_work_order_task_id AS "Id",
    _pwot.alternative_description AS "AlternativeDescription",
    _pwot.asset_id AS "AssetId",
    _pwot.asset_task_id AS "AssetTaskId",
    _pwot.default_interval_id AS "DefaultIntervalId",
    _pwot.description AS "Description",
    _pwot.due_date AS "DueDate",
    _pwot.due_reading AS "DueReading",
    _pwot.event_id AS "EventId",
    _pwot.failed_reason AS "FailedReason",
    _pwot.interval_type_id AS "IntervalTypeId",
    _pwot.is_statutory AS "IsStatutory",
    _pwot.is_suppressed AS "IsSuppressed",
    _pwot.last_done_date AS "LastDoneDate",
    _pwot.last_done_reading AS "LastDoneReading",
    _pwot.machine_state AS "MachineState",
    _pwot.meter_id AS "MeterId",
    _pwot.monitoring_point_id AS "MonitoringPointId",
    _pwot.motion_type AS "MotionType",
    _pwot.proposed_work_order_id AS "ProposedWorkOrderId",
    _pwot.responsible_section_id AS "ResponsibleSectionId",
    _pwot.responsible_staff_member_resource_id AS "ResponsibleStaffMemberResourceId",
    _pwot.responsible_trade_id AS "ResponsibleTradeId",
    _pwot.scheduling_kind AS "SchedulingKind",
    _pwot.scheduling_method AS "SchedulingMethod",
    _pwot.suppressed_by AS "SuppressedBy",
    _pwot.total_downtime AS "TotalDowntime",
    _pwot.total_duration AS "TotalDuration",
    _pwot.type_of_work_id AS "TypeOfWorkId",
    _pwot.permission_tree_id AS "_pwot_permission_tree_id"
FROM
    wm.proposed_work_order_task _pwot
    JOIN permission_tree_ids permission_join ON _pwot.permission_tree_id = permission_join.permission_tree_id


Query 4

Primary Table Alias Include References Include Permissions
_pwot True True
Parameter Name Data Type Value
@permission_user_id Bigint 500000000000
@permission_id Bigint 100120100
WITH permission_tree_ids AS
(
    SELECT DISTINCT unnest(psd.permission_tree_ids) AS permission_tree_id FROM uam.user_permission up JOIN uam.permission_set_data psd ON up.permission_set_id = psd.permission_set_id WHERE up.user_id = @permission_user_id AND up.permission_id = @permission_id
)
SELECT
    _u.user_id AS "CreatedByUserId",
    _u.code AS "CreatedByUserCode",
    _u.full_name AS "CreatedByUserFullName",
    _pwot.created_on AS "CreatedOn",
    _u1.user_id AS "ModifiedByUserId",
    _u1.code AS "ModifiedByUserCode",
    _u1.full_name AS "ModifiedByUserFullName",
    _pwot.modified_on AS "ModifiedOn",
    _pwot.version AS "Version",
    _pt.permission_tree_id AS "PermissionTreeId",
    _pt.code AS "PermissionTreeCode",
    _pt.description AS "PermissionTreeDescription",
    _s.site_id AS "SiteId",
    _s.code AS "SiteCode",
    _s.description AS "SiteDescription",
    _pwot.proposed_work_order_task_id AS "Id",
    _pwot.alternative_description AS "AlternativeDescription",
    _a.asset_id AS "AssetId",
    _a.code AS "AssetCode",
    _at.asset_task_id AS "AssetTaskId",
    _at.code AS "AssetTaskCode",
    _at.description AS "AssetTaskDescription",
    _at.inspection_type AS "AssetTaskInspectionType",
    _ti.task_interval_id AS "DefaultIntervalId",
    _ti.code AS "DefaultIntervalCode",
    _ti.description AS "DefaultIntervalDescription",
    _ti.task_interval_type_id AS "DefaultIntervalTaskIntervalType",
    _tit.task_interval_type_id AS "DefaultIntervalTaskIntervalTypeId",
    _pwot.description AS "Description",
    _pwot.due_date AS "DueDate",
    _pwot.due_reading AS "DueReading",
    _e.event_id AS "EventId",
    _e.code AS "EventCode",
    _e.description AS "EventDescription",
    _pwot.failed_reason AS "FailedReason",
    _tit1.task_interval_type_id AS "IntervalTypeId",
    _tit1.code AS "IntervalTypeCode",
    _tit1.description AS "IntervalTypeDescription",
    _tit1.scheduling_kind AS "IntervalTypeSchedulingKind",
    _pwot.is_statutory AS "IsStatutory",
    _pwot.is_suppressed AS "IsSuppressed",
    _pwot.last_done_date AS "LastDoneDate",
    _pwot.last_done_reading AS "LastDoneReading",
    _pwot.machine_state AS "MachineState",
    _m.meter_id AS "MeterId",
    _m.code AS "MeterCode",
    _m.last_reading AS "MeterLastReading",
    _m.average_daily_rate AS "MeterAverageDailyRate",
    _m.cumulative_reading AS "MeterCumulativeReading",
    _m.last_read_on AS "MeterLastReadOn",
    _m.notes AS "MeterNotes",
    _m.description AS "MeterDescription",
    _mp.monitoring_point_id AS "MonitoringPointId",
    _mp.code AS "MonitoringPointCode",
    _mp.description AS "MonitoringPointDescription",
    _mp.is_calculated AS "MonitoringPointIsCalculated",
    _mp.monitoring_point_type_id AS "MonitoringPointMonitoringPointType",
    _mpt.monitoring_point_type_id AS "MonitoringPointMonitoringPointTypeId",
    _mpt.code AS "MonitoringPointMonitoringPointTypeCode",
    _mpt.description AS "MonitoringPointMonitoringPointTypeDescription",
    _pwot.motion_type AS "MotionType",
    _pwo.proposed_work_order_id AS "ProposedWorkOrderId",
    _pwo.description AS "ProposedWorkOrderDescription",
    _s1.section_id AS "ResponsibleSectionId",
    _s1.code AS "ResponsibleSectionCode",
    _s1.description AS "ResponsibleSectionDescription",
    _r.resource_id AS "ResponsibleStaffMemberResourceId",
    _r.code AS "ResponsibleStaffMemberResourceCode",
    _r.description AS "ResponsibleStaffMemberResourceDescription",
    _r.resource_type AS "ResponsibleStaffMemberResourceResourceType",
    _rcd.resource_contact_detail_id AS "ResponsibleStaffMemberResourceContactDetailId",
    _rcd.first_name AS "ResponsibleStaffMemberResourceContactDetailFirstName",
    _rcd.last_name AS "ResponsibleStaffMemberResourceContactDetailLastName",
    _rcd.department AS "ResponsibleStaffMemberResourceContactDetailDepartment",
    _rcd.job_title AS "ResponsibleStaffMemberResourceContactDetailJobTitle",
    _r.site_id AS "ResponsibleStaffMemberResourceSite",
    _s2.site_id AS "ResponsibleStaffMemberResourceSiteId",
    _s2.code AS "ResponsibleStaffMemberResourceSiteCode",
    _s2.description AS "ResponsibleStaffMemberResourceSiteDescription",
    _t.trade_id AS "ResponsibleTradeId",
    _t.code AS "ResponsibleTradeCode",
    _t.description AS "ResponsibleTradeDescription",
    _pwot.scheduling_kind AS "SchedulingKind",
    _pwot.scheduling_method AS "SchedulingMethod",
    _pwot.suppressed_by AS "SuppressedBy",
    _pwot.total_downtime AS "TotalDowntime",
    _pwot.total_duration AS "TotalDuration",
    _tow.type_of_work_id AS "TypeOfWorkId",
    _tow.code AS "TypeOfWorkCode",
    _tow.description AS "TypeOfWorkDescription",
    _tow.work_type AS "TypeOfWorkWorkType",
    _tow.work_class AS "TypeOfWorkWorkClass",
    _pwot.permission_tree_id AS "_pwot_permission_tree_id",
    _u.permission_tree_id AS "_u_permission_tree_id",
    _u1.permission_tree_id AS "_u1_permission_tree_id",
    _s.permission_tree_id AS "_s_permission_tree_id",
    _a.permission_tree_id AS "_a_permission_tree_id",
    _at.permission_tree_id AS "_at_permission_tree_id",
    _ti.permission_tree_id AS "_ti_permission_tree_id",
    _tit.permission_tree_id AS "_tit_permission_tree_id",
    _e.permission_tree_id AS "_e_permission_tree_id",
    _tit1.permission_tree_id AS "_tit1_permission_tree_id",
    _m.permission_tree_id AS "_m_permission_tree_id",
    _mp.permission_tree_id AS "_mp_permission_tree_id",
    _mpt.permission_tree_id AS "_mpt_permission_tree_id",
    _pwo.permission_tree_id AS "_pwo_permission_tree_id",
    _s1.permission_tree_id AS "_s1_permission_tree_id",
    _r.permission_tree_id AS "_r_permission_tree_id",
    _s2.permission_tree_id AS "_s2_permission_tree_id",
    _t.permission_tree_id AS "_t_permission_tree_id",
    _tow.permission_tree_id AS "_tow_permission_tree_id"
FROM
    wm.proposed_work_order_task _pwot
    JOIN permission_tree_ids permission_join ON _pwot.permission_tree_id = permission_join.permission_tree_id
    JOIN uam.user _u ON _pwot.created_by_user_id = _u.user_id
    JOIN uam.user _u1 ON _pwot.modified_by_user_id = _u1.user_id
    JOIN uam.permission_tree _pt ON _pwot.permission_tree_id = _pt.permission_tree_id
    LEFT JOIN gen.site _s ON _pwot.site_id = _s.site_id
    JOIN ampc.asset _a ON _pwot.asset_id = _a.asset_id
    JOIN ampc.asset_task _at ON _pwot.asset_task_id = _at.asset_task_id
    LEFT JOIN ampc.task_interval _ti ON _pwot.default_interval_id = _ti.task_interval_id
    LEFT JOIN ampc.task_interval_type _tit ON _ti.task_interval_type_id = _tit.task_interval_type_id
    LEFT JOIN ampc.event _e ON _pwot.event_id = _e.event_id
    LEFT JOIN ampc.task_interval_type _tit1 ON _pwot.interval_type_id = _tit1.task_interval_type_id
    LEFT JOIN aom.meter _m ON _pwot.meter_id = _m.meter_id
    LEFT JOIN ahm.monitoring_point _mp ON _pwot.monitoring_point_id = _mp.monitoring_point_id
    LEFT JOIN ahm.monitoring_point_type _mpt ON _mp.monitoring_point_type_id = _mpt.monitoring_point_type_id
    JOIN wm.proposed_work_order _pwo ON _pwot.proposed_work_order_id = _pwo.proposed_work_order_id
    LEFT JOIN res.section _s1 ON _pwot.responsible_section_id = _s1.section_id
    LEFT JOIN res.resource _r ON _pwot.responsible_staff_member_resource_id = _r.resource_id
    LEFT JOIN res.resource_contact_detail _rcd ON _r.resource_id = _rcd.resource_contact_detail_id
    LEFT JOIN gen.site _s2 ON _r.site_id = _s2.site_id
    LEFT JOIN res.trade _t ON _pwot.responsible_trade_id = _t.trade_id
    JOIN ampc.type_of_work _tow ON _pwot.type_of_work_id = _tow.type_of_work_id