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 9119661
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:26:58+00:00 2026-06-17T05:26:58+00:00

I hope this doesn’t violate any rules (i’m new, and yes i did check

  • 0

I hope this doesn’t violate any rules (i’m new, and yes i did check the FAQ).

But i have the following code

SELECT DISTINCT PO_NUMBER, PO_TRACKING_NO, SUPPLIER, MIN(PO_QUANTITY),    
      SUM(SHIPPED_WT), PO_SHIPMENT_TO 
FROM VW_TRAFFIC_PO_SIDE
WHERE SYSDATE > PO_SHIPMENT_TO AND
      (PO_QUANTITY > SHIPPED_WT OR PO_TRACKING_NO IS NULL) 
GROUP BY PO_NUMBER, PO_TRACKING_NO, SUPPLIER, PO_SHIPMENT_TO
HAVING PO_QUANTITY > SUM(SHIPPED_WT)

It is suppose to do the following:
Display 1 PO# per Tracking No, [this is the distinct, and it is correct, i was able to compiple the code successfully]…next, and this is the tricky part (this is the SUM, MIN, GROUP BY and HAVING parts): I needed to combine the SHIPPED_WT of any PO_NUMBER (that is displayed), and to show that combined number if it is less than the PO_Quantity

the where statement is also correct, as i compiled it successfully, it was only when i added the above part that i ran into trouble.

EDIT: the above code NOW compile (thanks to the answer below)

HOWEVER, my logic is wrong, and it does not do what i would want it to do..the one thing it does do correctly is grab 1 PO_NUMBER with 1 PO_TRACKING_NO (there can be duplicate po_numbers as long as the PO_tracking_no is different, and there can be duplicate tracking as long as the number is different)

EDIT: Below is what the relevant columns look like, and i will explain what is wrong with it (and what i tried to do with the code that was revised

PO_NUMBER    PO_TRACKING_NO      MIN(PO_QUANTITY)  SUM(SHIPPED_WT)
123          C100                1000              750
123          C101                1000              250

the code was suppose to take records like this, and combine the SHIPPED_WT into one number (1000), and because that new number is = to the PO_QUANTITY, it should not appear in the query….in addition, the WHERE of PO_TRACKING_NO ISNULL is not working (all records with a null value in that field should be displayed, assuming it isn’t a duplicate of a PO_NUMBER and PO_TRACKING_NO)

  • 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-06-17T05:27:00+00:00Added an answer on June 17, 2026 at 5:27 am

    I don’t think you want to group by PO_TRACKING_NO. Also, your WHERE clause could accidentally exclude rows that you want; it’s the aggregates that you want to check (the HAVING clause). If you replace the NULLs with 0s using COALESCE then the HAVING clause should cover all of your cases:

    SELECT PO_NUMBER, MIN(PO_QUANTITY) AS PO_QUANTITY, SUM(COALESCE(SHIPPED_WT, 0)) AS SHIPPED_WT
    FROM VW_TRAFFIC_PO_SIDE
    WHERE SYSDATE > PO_SHIPMENT_TO
    GROUP BY PO_NUMBER
    HAVING MIN(PO_QUANTITY) > SUM(COALESCE(SHIPPED_WT, 0))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I do this? (The following code does NOT work, but I hope
I hope this makes sense, but I have an asp.net web forms application that
I hope this makes sense... It doesn't only apply to c#, but that is
I hope this doesn't come across as a stupid question but its something I
This is a simple one, I hope. How do I check, in the following
I hope this question isn't too dumb. We have many websites internally that need
Hope this doesn't get too complicated. :) thing is.. I'm trying to make my
first I want to say that I hope this doesn't look like I am
I am new to multithreading (and also to C#) so I hope this is
I hope this is still programming related, as SuperUser doesn't seem the appropriate place.

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.