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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T20:42:53+00:00 2026-05-14T20:42:53+00:00

Here is my table CusOrder that collect customer order OrderID Cus_ID Product_ID NumberOrder OrderDate

  • 0

Here is my table CusOrder that collect customer order

OrderID       Cus_ID    Product_ID  NumberOrder      OrderDate
   1        0000000001      9          1        6/5/2553 0:00:00
   2        0000000001     10          1        6/5/2553 0:00:00
   3        0000000004      9          2        13/4/2553 0:00:00
   4        0000000004      9           1        17/3/2553 0:00:00
   5        0000000002      9           1        22/1/2553 0:00:00
   7        0000000005      9           1        16/12/2552 0:00:00
   8        0000000003      9           3        13/12/2552 0:00:00
  10        0000000001      9           2        19/11/2552 0:00:00
  11        0000000003      9           2        10/11/2552 0:00:00
  12        0000000002      9           1        23/11/2552 0:00:00

I need to select 3 lastest order for each customer and I need all customer
so it will show each customer and his/her 3 lastest order
how can I do it

sorry for my bad english

  • 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-14T20:42:54+00:00Added an answer on May 14, 2026 at 8:42 pm
    WITH Temp AS
    (
        SELECT *, (ROW_NUMBER() OVER (PARTITION BY Cus_ID ORDER BY OrderDate DESC)) AS Number
        FROM CusOrder
    )
    SELECT * FROM Temp WHERE Number <= 3
    

    Should work. Not tested with this exact database structure, but something similar.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

While designing a table my colleague here says that I should avoid identity column
From here ALTER TABLE ORDERS ADD FOREIGN KEY (customer_sid) REFERENCES CUSTOMER(SID); How do I
Replaces Question: Update multiple rows into SQL table Here's a Code Snippet to update
Here's my table: CREATE TABLE `alums_alumphoto` ( `id` int(11) NOT NULL auto_increment, `alum_id` int(11)
Here is a simplification of my database: Table: Property Fields: ID, Address Table: Quote
Here is a simple scenario with table characters: CharacterName GameTime Gold Live Foo 10
Here's my scenario: I've got a table of (let's call them) nodes. Primary key
Here's my case: I have a table view showing contacts. Add button in the
Here is an example of what I've got going on: CREATE TABLE Parent (id
Here's the .jsp code: <table> <s:iterator value=allAgents> <tr> <td><s:property value=firstName /></td> <td><s:property value=middleName /></td>

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.