Results 1 to 3 of 3

Thread: If argument in SQL query

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Question If argument in SQL query

    Hi All,
    I have the following query written in Excel (VBA), but isthere a way to insert an if/then /else statement into it?

    [vba]
    SQL = "SELECT #tmpFR10.MySelect, #tmpFR10.Tpnd,#tmpFR10.Descrip, #tmpBSQB.Act_BOH, #tmpBSQB.PALLET_QTY, #tmpBSQB.sTOCK_I,#tmpBSQB.Multi_p, "
    SQL = SQL & "#tmpBSQB.s_dock, #tmpBSQB.non_s_dock,#tmpFR10.CUBE, #tmpFR10.Weight, LEFT(whs.dw_prodbpr.SubGroup,4),LEFT(whs.dw_prodbpr.SubGroup,3) FROM #tmpFR10 " _
    & " LEFT JOIN whs.Focus_Prodtut ON #tmpFR10.tpnd =whs.Focus_Prodtut.Tpnd " _
    & " LEFT JOIN whs.dw_prodbpr ONwhs.Focus_Prodtut.Tpnb = whs.dw_prodbpr.Tpnb " _
    & " LEFT JOIN #tmpBSQB ON #tmpFR10.TPND =#tmpBSQB.TPND"


    [/vba]


    In addition to the above I wish to say

    If #tmpBSQB.Act_BOH > (#tmpBSQB.s_dock + #tmpBSQB.non_s_dock)) THEN #tmpBSQB.Act_BOH ELSE (#tmpBSQB.s_dock +#tmpBSQB.non_s_dock)
    The results being output to a new column. i’m ok with VBA but only just starting with SQL.
    Any help would be appreciated. Thanks,























    Last edited by jazznaura; 08-30-2011 at 11:28 AM. Reason: VBA Tags not working

Posting Permissions

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