1

我卡在 sql 语句中。请在下面询问我

select 
                               

 master_brand.BRAND_NAME as AcCompanyID, 
                                    lewre_product.SKU_CODE as AcStockID,
                                    lewre_product.SKU_CODE as BarCode,
                                    lewre_product.SKU_CODE as StockBarCode,
                                    lewre_product.SKU_CODE as StockDescription1,
                                    NULL as StockDescription2,
                                    lewre_project.PROJECT_NAME as AcStockBrandID,
                                    lewre_artice.ARTICLE_NUMBER as AcStockGroupID,
                                    icenter_acStockCategory.CATEGORY_CODE as AcStockCategoryID,
                                    icenter_acStockColor.AcStockColorID as AcStockColorID,
                                    lewre_product.SIZE as AcStockSizeID,
                                    'NA' as ISBN,
                                    master_product_type.UOM as AcStockUOMID,
                                    lewre_article_price.FINAL_COST as StockCost,
                                    lewre_article_price.PRICE as StockPrice1,
                                    0 as StockPrice2,
                                    0 as StockPrice3,
                                    0 as StockPrice4,
                                    0 as StockPrice5,
                                    lewre_artice.CREATE_DATE
        
                          

 from [LEWRE.ARTICLE]as lewre_artice,
                                 [iCENTER.ACSTOCKCATEGORY]  as icenter_acStockCategory,
                                 [iCENTER.ACSTOCKCOLOR] as icenter_acStockColor,
                                 [LEWRE.PRODUCT] as lewre_product,
                                 [MASTER.BRAND] as master_brand,
                                 [LEWRE.PROJECT] as lewre_project,
                                 [MASTER.PRODUCT_TYPE] as master_product_type,
                                 [LEWRE.ARTICLE_PRICE] as lewre_article_price
         

                     

   where
                                (icenter_acStockCategory.CATEGORY_ID = lewre_artice.PRODUCT_CATEGORY_ID
                             AND icenter_acStockCategory.PRODUCT_TYPE_ID = lewre_artice.PRODUCT_TYPE_ID)
                             AND lewre_product.ARTICLE_ID = lewre_artice.ARTICLE_ID
                             and lewre_product.COLOR_ID = icenter_acStockColor.COLOR_ID
                             and master_brand.BRAND_ID = lewre_artice.BRAND_ID
                             and lewre_artice.PROJECT_ID = lewre_project.PROJECT_ID
                             and master_product_type.PRODUCT_TYPE_ID = lewre_artice.PRODUCT_TYPE_ID
                             and lewre_artice.ARTICLE_ID = lewre_article_price.ARTICLE_ID
                             and lewre_artice.CREATE_DATE 
                     
                             
                             
                             order by lewre_artice.CREATE_DATE
                                 

这是我得到的结果

在此处输入图像描述

我想选择 create_date 为当前日期的所有行。例如 (2012-04-30)' 。我怎样才能得到结果?请帮我

4

1 回答 1

2

将此添加到您的 where 子句中。

  lewre_artice.CREATE_DATE >= cast(getdate() as date) and 
  lewre_artice.CREATE_DATE < cast(dateadd(day, 1, getdate()) as date)

getdate()返回当前时间戳并cast(getdate() as date)删除时间部分。dateadd(day, 1, ....)增加一天。比较返回CREATE_DATE区间内的行。

于 2012-04-30T09:10:42.567 回答