CREATE VIEW [dbo].[V_Supplier_Warehouse_ShipVIA]
AS
        SELECT ROW_NUMBER()OVER(ORDER BY w.ID) AS 'ID'
        ,w.SupplierName
        ,w.TransportType
        , stuff((SELECT distinct top 5 ',' + '[' +c.WarehouseCode+'->'+c.SupplierWarehouseCode + ']' FROM Supplier_Warehouse AS c Where c.SupplierID = w.ID FOR xml path('')), 1, 1, '') AS WarehouseCode
        , stuff((SELECT distinct top 5 ',' + '[' + a.ShipVIA + '->' + a.CarrierCode + '->' + a.CarrierRouting + ']' FROM Supplier_ShipVIA AS a Where a.SupplierID = w.ID FOR xml path('')), 1, 1, '') AS ShipVIA
        ,(SELECT MIN(len(c.WarehouseCode)) FROM Supplier_Warehouse AS c Where c.SupplierID = w.ID) AS LenWarehouseCode
        ,(SELECT MIN(len(c.SupplierWarehouseCode)) FROM Supplier_Warehouse AS c Where c.SupplierID = w.ID) AS LenSupplierWarehouseCode
        ,(SELECT MIN(len(a.ShipVIA)) FROM Supplier_ShipVIA AS a Where a.SupplierID = w.ID) AS LenShipVIA
        ,(SELECT MIN(len(a.CarrierCode)) FROM Supplier_ShipVIA AS a Where a.SupplierID = w.ID) AS LenCarrierCode
        ,(SELECT MIN(len(a.CarrierRouting)) FROM Supplier_ShipVIA AS a Where a.SupplierID = w.ID) AS LenCarrierRouting
    FROM Supplier AS w

GO

相关文章:

  • 2022-03-09
  • 2021-06-06
  • 2022-12-23
  • 2022-12-23
  • 2021-11-23
  • 2021-11-23
  • 2021-11-23
猜你喜欢
  • 2021-11-23
  • 2022-01-07
  • 2021-08-08
  • 2022-03-05
  • 2021-05-07
  • 2021-11-23
  • 2021-09-20
相关资源
相似解决方案