Results 1 to 2 of 2

Thread: convering code

  1. #1
    Join Date
    May 2010
    Posts
    2

    Unanswered: convering code

    i have sending a code ms access code to convert into ms sql

    SELECT tblBias_TP_RCU_AB.[Primary Active Ingredient], Sum(IIf([In Range]="X",1,0))/Sum(IIf([Material]="X",1,0)) AS MAPE, tblBias_TP_RCU_AB.ChartDate INTO tmpBias_AI_TA_AB
    FROM tblBias_TP_RCU_AB
    WHERE (((tblBias_TP_RCU_AB.Material)="X"))
    GROUP BY tblBias_TP_RCU_AB.[Primary Active Ingredient], tblBias_TP_RCU_AB.ChartDate
    HAVING (((tblBias_TP_RCU_AB.ChartDate)>DateAdd("m",-25,[Forms]![frmSwitch]![Today])))
    ORDER BY tblBias_TP_RCU_AB.[Primary Active Ingredient], tblBias_TP_RCU_AB.ChartDate DESC;

    please answer soon ,its urgent

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Code:
    DECLARE @today datetime
        SET @today = DateAdd(dd, DateDiff(dd, 0, GetDate()), 0)
    
    SELECT tblBias_TP_RCU_AB.[Primary Active Ingredient]
         , tblBias_TP_RCU_AB.ChartDate
         , Sum(CASE WHEN [In Range] = 'X' THEN 1 ELSE 0 END) As MAPE
    INTO   tmpBias_AI_TA_AB
    FROM   tblBias_TP_RCU_AB
    WHERE  tblBias_TP_RCU_AB.Material = 'X'
    AND    tblBias_TP_RCU_AB.ChartDate > DateAdd("m", -25, @today)
    GROUP
        BY tblBias_TP_RCU_AB.[Primary Active Ingredient]
         , tblBias_TP_RCU_AB.ChartDate
    ORDER
        BY tblBias_TP_RCU_AB.[Primary Active Ingredient]
         , tblBias_TP_RCU_AB.ChartDate DESC
    George
    Home | Blog

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •