Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
SQL
ce
clients
clustering
connect
datamining
datawarehouse
dts
fulltext
jdbcdriver
msde
mseq
newusers
notificationsvcs
odbc
olap
programming
replication
reportingsvcs
security
securitytools
server
setup
sqlxml.viewmapper
tools
xml
  
 
date: Mon, 8 May 2006 09:32:01 -0700,    group: microsoft.public.sqlserver.mseq        back       


Last order date for each customer   
I would like to write a select statement in query analyzer which would return 
the last order number per customer given a specific order type.  (Which would 
be 1 record per customer)  Thanks.
date: Mon, 8 May 2006 09:32:01 -0700   author:   chas2006

Re: Last order date for each customer   
On Mon, 8 May 2006 09:32:01 -0700, chas2006 wrote:

>I would like to write a select statement in query analyzer which would return 
>the last order number per customer given a specific order type.  (Which would 
>be 1 record per customer)  Thanks.

Hi chas2006,

Questions like this are imppossible to answer without knowing how your
database looks. Please post table structure (as CREATE TABLE statements,
including constraints and properties), some rows of sample data (as
INSERT statements) and expected results.

Maybe something like this?

SELECT   Customer, MAX(OrderNumber)
FROM     Orders
WHERE    OrderType = 17
GROUP BY Customer

-- 
Hugo Kornelis, SQL Server MVP
date: Mon, 08 May 2006 22:13:01 +0200   author:   Hugo Kornelis LID

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us