Results 1 to 2 of 2

Thread: sql help

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2015
    Posts
    15

    sql help

    i need to substract the two columns sum(aantal) off the 2 sql commands , is it possible to put the 2 commands into one ?
    how can i do that ?


    "SELECT tblAKLeveringen.BestelbonId,BestelbonArtID, sum(Aantal) as GeleverdAantal " &
    "FROM tblAKLeveringenArt " &
    "LEFT JOIN tblAKLeveringen on tblAKLeveringenArt.LeveringsbonID = tblAKLeveringen.ID " &
    "WHERE tblAKLeveringen.BestelbonId = '" & intBestellingID & "' and bestelbonArtID='" & Opmaak.BestelbonArtID & "' and tblAKLeveringen.Status <>'Opmaak' "
    "GROUP BY BestelbonID, bestelbonArtID "

    and

    "SELECT tblAKRetour.BestelbonId,BestelbonArtID,HoeAfhandelen, sum(Aantal) as GeleverdAantal " &
    "FROM tblAKRetourArt " &
    "LEFT JOIN tblAKRetour on tblAKRetourArt.RetourbonID = tblAKRetour.ID " &
    "WHERE tblAKRetour.BestelbonId = '" & intBestellingID & "' and bestelbonArtID='" & Opmaak.BestelbonArtID & "' and tblAKRetour.Status <>'Opmaak " &
    " and HoeAfhandelen = 'Nog te leveren' " &
    "GROUP BY BestelbonID, bestelbonArtID ")
    Last edited by jdsoft; Jun 26th, 2017 at 12:06 PM.

  2. #2
    PowerPoster
    Join Date
    Jun 2015
    Posts
    2,224

    Re: sql help

    subtract which from which?

    Here they are combined subtracting the second from the first.

    Code:
    "SELECT tblAKRetour.BestelbonId,BestelbonArtID,HoeAfhandelen, sum(Aantal) as GeleverdAantal " &
    "FROM tblAKRetourArt " &
    "LEFT JOIN tblAKRetour on tblAKRetourArt.RetourbonID = tblAKRetour.ID " &
    "WHERE tblAKRetour.BestelbonId = '" & intBestellingID & "' and bestelbonArtID='" & Opmaak.BestelbonArtID & "' and tblAKRetour.Status <>'Opmaak " &
    " and HoeAfhandelen <> 'Nog te leveren' " & 
    "GROUP BY BestelbonID, bestelbonArtID ")

Posting Permissions

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



Click Here to Expand Forum to Full Width