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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T06:45:26+00:00 2026-05-17T06:45:26+00:00

Both of these work individually SELECT PONumber, count(RequestNumber) as InNumOfRequests, sum(Amount) as SumofAmounts FROM

  • 0

Both of these work individually

SELECT  PONumber, 
        count(RequestNumber) as "InNumOfRequests", 
        sum(Amount) as "SumofAmounts" 
FROM tableView
GROUP BY PONumber  

SELECT DISTINCT PONumber, 
                (10 * ceiling((DATEDIFF(day,POApprovedDate,GETDATE()))/10)) 
                  AS "BINofDaysSincePOApproved"                      
FROM tableView

And I want to end up with:

PONumber   |  InNumOfRequests  |  SumofAmounts  |  BINofDaysSincePOApproved  
PO1        |  2                |  100           |  180
PO2        |  1                |  50            |  179   

tableView looks like:

RequestNumber | PONumber | Amount  |  POApproved Date   
1             | PO1      | 100.00  |  2010-01-01  
2             | PO1      | 100.00  |  2010-01-01  
3             | PO2      |  50.00  |  2010-01-02

note that PO1 is actually the PO for 2 requests and so the POApproved Data and Amount is the same for those 2 requests.

It seems easy but from the book I’m using (The Language of SQL) i can’t figure it out.
Help 🙁
Alex

  • 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-17T06:45:27+00:00Added an answer on May 17, 2026 at 6:45 am
    SELECT *
       FROM (
             SELECT PONumber, count(RequestNumber) as "InNumOfRequests", sum(Amount) as "SumofAmounts"
               FROM tableView
              GROUP BY PONumber
            ) a,
            (
             SELECT DISTINCT PONumber, (10 * ceiling((DATEDIFF(day, POApprovedDate, GETDATE()))/10)) AS "BINofDaysSincePOApproved"
               FROM tableView
            ) b
     WHERE a.PONumber = b.PONumber
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a picklist web interface: a pair of select elements with a pair
I have two MySQL databases for my site - one is for a production
I asked this question previously but the answers weren't what I was looking for.
I am trying to implement a fulltext search on two columns which I created
So if you look at my other posts, it's no surprise I'm building a
I have a web app in production that is used for typical data entry,retrieval,
I didn't quite get / see what I was hoping for and maybe missed,
I can set the margin of a stackpanel in code-behind like this: StackPanel sp2
I am having a problem with using session variables. I have two controllers named
I have recently started using CAML.NET IntelliSense for SharePoint with Visual Studio 2008; which

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.