Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old January 20th, 2004, 06:19 AM
Registered User
 
Join Date: Jan 2004
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to get max value within same id

Dear all
I had a table which contain user_id and expenses_amount.what sql i should use to pick up the most largest value in expenses_amount with a same id.
Here is an example :

     User_id Exp_amt
     102111 5000
     102111 600
     102111 7800

then the bingo record = 102111 7800

Thx alot
Jack

Reply With Quote
  #2 (permalink)  
Old January 20th, 2004, 06:26 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: London, , United Kingdom.
Posts: 132
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Well, you could use
Code:
Select User_ID, Max(Exp_amt)
From YourTable
Where User_ID = 'insert reqd id here'
Or if you want every user listed
Code:
Select User_ID, Max(Exp_amt)
From YourTable
Group By User_ID
Order By User_ID desc
HTH



There are two secrets to success in this world:
1. Never tell everything you know
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
'this.ID = id;' in class construction holf BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 0 October 6th, 2006 10:58 AM
select Max 2 rows for each ID veeruu SQL Language 1 January 31st, 2006 04:08 AM
Problem with displaying ID when finding max or min marcin2k Access VBA 1 October 3rd, 2005 07:42 AM
why not index.asp?id=1 can be www.myweb.com/?id=1 BurhanKhan Classic ASP Professional 11 September 6th, 2004 02:06 PM
Urgent please help to find Max ID and add 1 to it nhatrang71 Access 5 June 28th, 2004 10:24 PM



All times are GMT -4. The time now is 08:17 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.