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

  • Home
  • SEARCH
  • 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 747529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T14:12:56+00:00 2026-05-14T14:12:56+00:00

I am relatively new with sql and I need some help with some basic

  • 0

I am relatively new with sql and I need some help with some basic query construction.

Problem: To retrieve the number of orders and the customer id from a table based on a set of parameters.

I want to write a query to figure out the number of orders under each customer (Column: Customerid) along with the CustomerID where the number of orders should be greater or equal to 10 and the status of the order should be Active. Moreover, I also want to know the first transaction date of an order belonging to each customerid.

Table Description:

product_orders

Orderid CustomerId Transaction_date Status
------- ---------- ---------------- -------
 1       23         2-2-10          Active
 2       22         2-3-10          Active
 3       23         2-3-10          Deleted
 4       23         2-3-10          Active

Query that I have written:

select count(*), customerid
  from product_orders
 where status = 'Active'
 GROUP BY customerid
 ORDER BY customerid;

The above statement gives me

  • the sum of all order under a customer
    id but does not fulfil the condition
    of atleast 10 orders.
  • I donot know how
    to display the first transaction date
    along with the order under a
    customerid (status: could be active
    or delelted doesn’t matter)

Ideal solutions should look like:

Total Orders CustomerID Transaction Date (the first transaction date)
------------ ---------- ----------------
11           23         1-2-10

Thanks in advance. I hope you guys would be kind enough to stop by and help me out.

Cheers,

Leonidas

  • 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-14T14:12:56+00:00Added an answer on May 14, 2026 at 2:12 pm
    SELECT
        COUNT(*) AS [Total Orders],
        CustomerID,
        MIN(Transaction_date) AS [Transaction Date]
    FROM product_orders
    WHERE product_orders.Status = 'Active'
    GROUP BY
        CustomerId
    HAVING COUNT(*) >= 10
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am relatively new to sql and asp. My problem is that i need
I'm encountering some peculiarities with LINQ to SQL. With a relatively simple query, I
I'm relatively new SQL queries, and I'm trying to join two tables in order
I am relatively new to SQL, so I had a question about insertion. I
I'm an experienced programmer, but relatively new to SQL. We're using Oracle 10 and
I need to export the resulting data from a query in PostgreSQL to Excel/CSV.
I'm relatively new to sql so this may probably come off as a simple
I'm relatively new to C# and SQL work and I currently have an application
I am relatively new to MVC3, and am developing a website that will need
Ok so I am new here :) I am relatively new to SQL, and

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.