如何在一列中排除包含空白信息的行

时间:2017-06-27 09:29:41

标签: sql stored-procedures view report

我有这个脚本

USE [KevinMayhewLive]
GO
/****** Object:  View [dbo].[KM_SALES_DATA]    Script Date: 06/27/2017 10:23:02 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER VIEW [dbo].[KM_SALES_DATA]
--Natika Edward 28/03/17
--Pull Sales Order Data
AS

 SELECT
 "SL_ACCOUNTS"."CUCODE"  AS [Customer Code],
  "ORD_DETAIL"."OD_ORDER_NUMBER" AS [Order Number],
    CONVERT(VARCHAR(10),"ORD_DETAIL"."OD_DATE_PUTIN",103) AS [Date of 
Purchase],
    "ORD_DETAIL"."OD_STOCK_CODE" AS [Item],
     "ORD_DETAIL"."OD_QTYORD" AS [Quantity Ordered],
      "ORD_DETAIL"."OD_UNITCST" AS [Unit Cost],
       "ORD_DETAIL"."OD_GROSS" AS [C_AMT_SALES], 
        "ORD_HEADER"."OH_USER2" AS [Order Origin],
        "CRM_CAMPAIGN"."CMP_CODE" AS [Campaign Code]
 FROM   (("KevinMayhewLive"."dbo"."ORD_DETAIL" "ORD_DETAIL" 
 INNER JOIN "KevinMayhewLive"."dbo"."ORD_HEADER" "ORD_HEADER" ON 
"ORD_DETAIL"."OD_ORDER_NUMBER"="ORD_HEADER"."OH_ORDER_NUMBER") 
 INNER JOIN "KevinMayhewLive"."dbo"."CRM_CAMPAIGN" "CRM_CAMPAIGN" ON 
"ORD_HEADER"."OH_CAMPAIGN_LINK"="CRM_CAMPAIGN"."CMP_PRIMARY") 
 INNER JOIN "KevinMayhewLive"."dbo"."SL_ACCOUNTS" "SL_ACCOUNTS" ON 
"ORD_HEADER"."OH_ACCOUNT"="SL_ACCOUNTS"."CUCODE"
 --where CONVERT(VARCHAR(10),"ORD_DETAIL"."OD_DATE_PUTIN",103) = 
CONVERT(VARCHAR(10),GETDATE(),103) --take out hyphens to run report and 
bring back daily figures. 

要提取销售订单数据,它还包括没有库存代码的邮资和文本行,我需要在没有代码的情况下排除这些行......是什么想法?

1 个答案:

答案 0 :(得分:0)

WHERE "ORD_DETAIL"."OD_STOCK_CODE IS NOT NULL OR "ORD_DETAIL"."OD_STOCK_CODE" <> ''放在代码的末尾。