473,395 Members | 1,496 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Last order made by customer from a table

I have 500 customers and 50 type of products with 20 colours each and 5 to 6 type of designs for each product. I want to retrieve data for each customer last order details. Fields in table are
C_Name P_Name Colour Designs Order date
Jun 25 '15 #1
1 1210
Seth Schrock
2,965 Expert 2GB
The following query will get the last order by customer. If the field Order date is just a date field and the customer makes two orders on the same day, both orders will be included.
Expand|Select|Wrap|Line Numbers
  1. SELECT Lst.C_Name
  2.     , Table_Name.P_Name
  3.     , Table_Name.Colour
  4.     , Table_Name.Designs
  5.     , Lst.[Order date]
  6. FROM
  7.     (SELECT C_Name, Max([Order date]) As LastOrder
  8.     FROM Table_Name
  9.     GROUP BY C_Name) As Lst INNER JOIN Table_Name
  10.     ON Lst.C_Name = Table_Name.C_Name 
  11.         And Lst.LastOrder = Table_Name.[Order date]
Jun 25 '15 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Nick | last post by:
I wrote a news script to post news posts in reverse chronological order. I'd like a page to post the last 6 posts from a page, from newest to oldest. But as it is, I don't know how to find...
0
by: simon | last post by:
When user clicks SAVE button, it creates a new order with some products. I open connection, set isolation level on adXactIsolated(1048576) - because I have trigger on tables, and then begin...
3
by: jef3fowler | last post by:
Drawn a blank. Looking to find the last date each client ordered something. The query should show each client and the last order date. 2 tables: Clients and orders. clientID in each. Any...
1
by: Sakakini | last post by:
How can I append last entry from one table to another table???
1
by: Simon | last post by:
Dear reader, I made a table and now I do not know in which mdb the table is stored. Is there any help to search for a table in several mdb's even if you do not know the complete table name...
2
oszapped
by: oszapped | last post by:
I am new to creating SQL queries and need some help. I am trying to query from three tables. 1 - A table with a list of Drawings (DRAWINGS) 2 - A table with the Revision history of the Drawings...
3
chathura86
by: chathura86 | last post by:
hi i want to get the last row of a table but this table has another table in each cell so var rows = table.getElementsByTagName('tr'); var lastrow = rows;
5
by: DanicaDear | last post by:
I have an existing DB that has a customer table with all sorts of handy information. There are a lot of other tables but it's this customer table in particular that this post is about. I want to...
1
by: webtechbharathi | last post by:
I want develop customer table. here i want create customer id like cus01 .i insert into more customer its automatically add id cus02 next automatically increase cus03 etc,in php mysql how to do this...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.