NJC__Documentation::DB

dbo.vw_part_list_production_detail

Description

Properties

Name Value
Collation SQL_Latin1_General_CP1_CI_AS
ANSI Nulls ON

True

Quoted Identifier ON

True

Encrypted

False

Schema Bound

False

Created 11/6/2020 19:06:29
Last Modified 11/6/2020 19:06:29

Columns

Key Name Description
ms_part_list_production_detail_id
ms_part_list_production_id
ms_item_id
part_no
part_name
ms_item_base_no
uom
quantity
quantity_bom
quantity_new_part
quantity_recycle
total_supply
r_s
create_date
create_by
modify_date
modify_by

SQL Script

SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO





CREATE VIEW dbo.vw_part_list_production_detail
AS
SELECT        
b.ms_part_list_production_detail_id
, b.ms_part_list_production_id
, b.ms_item_id
, a.part_no
, a.part_name
, a.ms_item_base_no
, a.uom
, b.quantity
, ISNULL(b.quantity/dbo.dt_ms_part_list_production_header.quantity,0) AS quantity_bom
, ISNULL(c.quantity_new_part, 0) AS quantity_new_part
, ISNULL(c.quantity_recycle, 0) AS quantity_recycle
, ISNULL(c.total_supply, 0) AS total_supply
, CAST(CASE WHEN isnull(c.total_supply, 0) < b.quantity THEN 1 WHEN isnull(c.total_supply, 0) > b.quantity THEN 2 ELSE 0 END AS int) AS r_s
, b.create_date
, users_create.username AS create_by
, b.modify_date
, users_modify.username AS modify_by
FROM dbo.dt_ms_item AS a 
INNER JOIN dbo.dt_ms_part_list_production_detail AS b ON a.ms_item_id = b.ms_item_id 
INNER JOIN dbo.dt_ms_part_list_production_header  ON b.ms_part_list_production_id = dbo.dt_ms_part_list_production_header.ms_part_list_production_id
LEFT OUTER JOIN dbo.vw_part_list_production_detail_sum_supply AS c ON b.ms_part_list_production_detail_id = c.ms_part_list_process_detail_id 
LEFT OUTER JOIN dbo.users AS users_create ON b.create_by = users_create.id 
LEFT OUTER JOIN dbo.users AS users_modify ON b.modify_by = users_modify.id


GO