Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Select count on 2 DBF files

Select count on 2 DBF files

Scheduled Pinned Locked Moved Database
question
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jkirkerx
    wrote on last edited by
    #1

    Sort of a dumb question here, I have 2 DBF files, fox-pro DBF files that are identical, in which I want to union all and get the count of the FITEMNO, which there is 1 in the first file and 1 in the 2nd file, so I get a count of 2. Is this normal behavior or did I construct the statement wrong below?

    SELECT COUNT(FITEMNO) AS hCount
    FROM
    (
    SELECT
    FITEMNO
    FROM ARTRS01H.dbf
    WHERE
    FSHIPDATE >= @startDate AND FSHIPDATE <= @stopDate
    AND
    FCUSTNO = @FCUSTNO
    AND
    FITEMNO = @FITEMNO
    GROUP BY FITEMNO
    UNION ALL
    SELECT
    FITEMNO
    FROM ARTRS01H.dbf
    WHERE
    FSHIPDATE >= @startDate AND FSHIPDATE <= @stopDate
    AND
    FCUSTNO = @FCUSTNO
    AND
    FITEMNO = @FITEMNO
    GROUP BY FITEMNO
    )

    P 1 Reply Last reply
    0
    • J jkirkerx

      Sort of a dumb question here, I have 2 DBF files, fox-pro DBF files that are identical, in which I want to union all and get the count of the FITEMNO, which there is 1 in the first file and 1 in the 2nd file, so I get a count of 2. Is this normal behavior or did I construct the statement wrong below?

      SELECT COUNT(FITEMNO) AS hCount
      FROM
      (
      SELECT
      FITEMNO
      FROM ARTRS01H.dbf
      WHERE
      FSHIPDATE >= @startDate AND FSHIPDATE <= @stopDate
      AND
      FCUSTNO = @FCUSTNO
      AND
      FITEMNO = @FITEMNO
      GROUP BY FITEMNO
      UNION ALL
      SELECT
      FITEMNO
      FROM ARTRS01H.dbf
      WHERE
      FSHIPDATE >= @startDate AND FSHIPDATE <= @stopDate
      AND
      FCUSTNO = @FCUSTNO
      AND
      FITEMNO = @FITEMNO
      GROUP BY FITEMNO
      )

      P Offline
      P Offline
      PIEBALDconsult
      wrote on last edited by
      #2

      That's what you asked for. Suggestions: 0) Move the GROUP BY to the outer SELECT or 1) Use SUM in the outer SELECT

      J 1 Reply Last reply
      0
      • P PIEBALDconsult

        That's what you asked for. Suggestions: 0) Move the GROUP BY to the outer SELECT or 1) Use SUM in the outer SELECT

        J Offline
        J Offline
        jkirkerx
        wrote on last edited by
        #3

        OK, Thanks That's what I thought.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups