hur.cn - 华软网

 热门搜索

这样的SQL语句帮我看看还能怎么优化一下

  作者:未知    来源:网络    更新时间:2017/9/26
SELECT distinct jd_clothing.RollID,
         jd_clothing.CarNo,
         jd_clothing.ColorID,
         Quantity = (case when (select XC_Unit.unitname 
                         from XC_Unit 
                                 where XC_Unit.unitcode = JD_label.labelunit) = '米' then jd_clothing.quantity 
                          else jd_clothing.quantity / (select XC_Unit.unitfact 
                                                        from XC_Unit 
                                                       where XC_Unit.unitcode = JD_label.labelunit )end ), 
         RollUnit = (case when JD_label.markmodel = 'E' then (case when (select XC_Unit.unitname 
                                                                          from XC_Unit 
                                                                         where XC_Unit.unitcode = JD_label.labelunit) = '米' 
                                                                  then 'METERS' else 'YARDS' end) 
                       else (case when (select XC_Unit.unitname 
                                          from XC_Unit 
                                          where XC_Unit.unitcode = JD_label.labelunit)= '米' 
                                  then '米(METERS)' else '码(YARDS)' end) end), 
         jd_clothing.DyeLot,
         MV_Product.P_ChnName,
         MV_Product.P_EngName,
         JD_label.chnfactory,
         JD_label.telephone,
         JD_label.chnaddress,
         JD_label.engaddress,
         JD_label.engfactory,
         rollid = (case when jd_clothing.rollid = 'Y' then
                   jd_clothing.rollid else cast('A' + rtrim(jd_clothing.rollid)+'B' as char(20) ) end)
    FROM jd_clothing,MV_Product,JD_label,MV_Plan
  WHERE(jd_clothing.PlanNo = MV_Product.PlanNo)and
         (MV_Plan.planno = MV_Product.planno)and
         (JD_label.customno = MV_Plan.customno)and
         (JD_label.customno ='KHNX002')and 
         (JD_label.labelid  = '5')and 
         (MV_Plan.valid<>'N')and
         (MV_Product.p_valid <> 'N')
------华软网友回答------
我对存储过程不太了解。高手们能不能帮我写一个存储过程啊
     
华软声明:本内容来自网络,如有侵犯您版权请来信指出,本站立即删除。