Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 20th, 2004, 07:19 AM
Registered User
 
Join Date: Jan 2004
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

 
Old January 20th, 2004, 07:26 AM
Friend of Wrox
 
Join Date: Jun 2003
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





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 05: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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.