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:05:20 |
| Last Modified | 11/6/2020 19:05:20 |
Columns
| Key | Name | Description |
|---|---|---|
| ms_part_list_change_part_detail_id | ||
| ms_part_list_change_part_id | ||
| ms_item_id | ||
| part_no | ||
| part_name | ||
| ms_item_base_no | ||
| ms_item_custom_no | ||
| uom | ||
| quantity | ||
| quantity_new_part | ||
| quantity_recycle | ||
| quantity_scrap | ||
| total_supply | ||
| r_s | ||
| create_date | ||
| create_by | ||
| modify_date | ||
| modify_by | ||
| ms_part_list_production_id |
SQL Script
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
CREATE VIEW dbo.vw_part_list_change_part_detail
AS
SELECT
b.ms_part_list_change_part_detail_id
, b.ms_part_list_change_part_id
, b.ms_item_id
, a.part_no
, a.part_name
, a.ms_item_base_no
, a.ms_item_custom_no
, a.uom
, b.quantity
, ISNULL(d.quantity_new_part, 0) AS quantity_new_part
, ISNULL(d.quantity_recycle, 0) AS quantity_recycle
, ISNULL(d.quantity_scrap, 0) AS quantity_scrap
, ISNULL(d.total_supply, 0) AS total_supply
, CAST(CASE WHEN isnull(d.total_supply, 0) < b.quantity THEN 1 WHEN isnull(d.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
, c.ms_part_list_production_id
FROM dbo.dt_ms_item AS a
INNER JOIN dbo.dt_ms_part_list_change_part_detail AS b ON a.ms_item_id = b.ms_item_id
INNER JOIN dbo.dt_ms_part_list_change_part_header AS c ON b.ms_part_list_change_part_id = c.ms_part_list_change_part_id
LEFT OUTER JOIN dbo.vw_part_list_change_part_detail_sum_supply AS d ON b.ms_part_list_change_part_detail_id = d.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
GO
CREATE VIEW dbo.vw_part_list_change_part_detail
AS
SELECT
b.ms_part_list_change_part_detail_id
, b.ms_part_list_change_part_id
, b.ms_item_id
, a.part_no
, a.part_name
, a.ms_item_base_no
, a.ms_item_custom_no
, a.uom
, b.quantity
, ISNULL(d.quantity_new_part, 0) AS quantity_new_part
, ISNULL(d.quantity_recycle, 0) AS quantity_recycle
, ISNULL(d.quantity_scrap, 0) AS quantity_scrap
, ISNULL(d.total_supply, 0) AS total_supply
, CAST(CASE WHEN isnull(d.total_supply, 0) < b.quantity THEN 1 WHEN isnull(d.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
, c.ms_part_list_production_id
FROM dbo.dt_ms_item AS a
INNER JOIN dbo.dt_ms_part_list_change_part_detail AS b ON a.ms_item_id = b.ms_item_id
INNER JOIN dbo.dt_ms_part_list_change_part_header AS c ON b.ms_part_list_change_part_id = c.ms_part_list_change_part_id
LEFT OUTER JOIN dbo.vw_part_list_change_part_detail_sum_supply AS d ON b.ms_part_list_change_part_detail_id = d.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