Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4620218
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:31:51+00:00 2026-05-22T02:31:51+00:00

I have this query for a DB2 DB where I need to pull data

  • 0

I have this query for a DB2 DB where I need to pull data between dates and specific times. I came up with the query below and it is working but is not getting the data for the day in between 20110510 and 20110512 in this case 20110511, this data should be for the entire day.

The dates and times are user’s parameters so this will change depending on their needs. I also want to be able to pull data for the same day with the same query if possible, for example:

Date last modify >= 20110512 AND
Date last modify <= 20110512 AND
Time last modify >= 090000   AND
Time last modify <= 230000   AND

Any help will be really appreciate it in advance. Thank you.

SELECT A1.CHCASN, A1.CHTRKN,
SUM(A2.CDPAKU) AS UNITS, A1.CHACWT, SUM(A2.CDPRC * A2.CDPAKU) AS COST, SUM(A3.STRPRC * A2.CDPAKU) AS RETAIL, A1.CHDLM, A1.CHTLM
FROM CHCART00 A1, CDCART00 A2, STSTYL00 A3
WHERE A1.CHCASN = A2.CDCASN
AND A2.CDSTYL = A3.STSTYL
AND A2.CDCOLR = A3.STCOLR
AND A2.CDSDIM = A3.STSDIM
AND A1.CHSTAT = '25'
AND (A1.CHDLM = 20110510 AND A1.CHTLM >= '200000' OR A1.CHDLM = 20110512 AND A1.CHTLM <= '092000') AND A1.CHROUT = 'UPSPA'
GROUP BY A1.CHCASN, A1.CHTRKN, A1.CHACWT, A1.CHDLM, A1.CHTLM
ORDER BY A1.CHDLM, A1.CHTLM
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T02:31:52+00:00Added an answer on May 22, 2026 at 2:31 am

    Examples:-

    (Between two dates)

    `SELECT A1.CHCASN, A1.CHTRKN, SUM(A2.CDPAKU) AS UNITS, A1.CHACWT,
        SUM(A2.CDPRC * A2.CDPAKU) AS COST, SUM(A3.STRPRC * A2.CDPAKU) AS RETAIL,     
        A1.CHDLM, A1.CHTLM FROM CHCART00 A1, CDCART00 A2, STSTYL00 A3  
    WHERE A1.CHCASN = A2.CDCASN AND A2.CDSTYL = A3.STSTYL AND      
        A2.CDCOLR = A3.STCOLR     AND A2.CDSDIM = A3.STSDIM AND A1.CHSTAT = '25' AND
        (A1.CHDLM BETWEEN 20110510 AND 20110512)      
        AND A1.CHROUT = 'UPSPA' GROUP BY A1.CHCASN, A1.CHTRKN, A1.CHACWT,
        A1.CHDLM, A1.CHTLM  
    ORDER BY A1.CHDLM, A1.CHTLM` 
    

    (Same date)

    `SELECT A1.CHCASN, A1.CHTRKN, SUM(A2.CDPAKU) AS UNITS, A1.CHACWT,
        SUM(A2.CDPRC * A2.CDPAKU) AS COST, SUM(A3.STRPRC * A2.CDPAKU) AS RETAIL,     
        A1.CHDLM, A1.CHTLM FROM CHCART00 A1, CDCART00 A2, STSTYL00 A3  
    WHERE A1.CHCASN = A2.CDCASN AND A2.CDSTYL = A3.STSTYL AND      
        A2.CDCOLR = A3.STCOLR     AND A2.CDSDIM = A3.STSDIM AND A1.CHSTAT = '25' AND
        (A1.CHDLM = 20110511)     
        AND A1.CHROUT = 'UPSPA' GROUP BY A1.CHCASN, A1.CHTRKN, A1.CHACWT,
        A1.CHDLM, A1.CHTLM  
    ORDER BY A1.CHDLM, A1.CHTLM `
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 2 databases namely db1,db2. I need a query that fetch the data
I have a DB2 query in a shell script which return an integer value,
I have the same issue using hibernate against DB2 and MySQL. Here is a
This is all going to have to be pseudo as I am on my
How do you do LIMIT in DB2 for iSeries? I have a table with
The follow query drops a table if the table exists but it doesnt seem
I realize my title probably doesnt explain my situation very well, but I honestly
Brief Description of the app: I have written a Delphi application that allows a
I've been assigned to develop a small Java application to process some data from
I have a console application with a few methods that: insert data1 (customers) from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.