Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server ASP
|
SQL Server ASP Discussions about ASP programming with Microsoft's SQL Server. For more ASP forums, see the ASP forum category.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server ASP 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 May 8th, 2007, 12:49 AM
Registered User
 
Join Date: May 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to nirmal_s19
Default Selecting MAX Value

cmd = new SqlCommand("Select isnull( max(date),0), isnull(max(balance),0) from chinnamaniaccounts where customerid='" + TextBox1.Text + "'", con);

I did used the above querry to call the value balance stored in the max date row. But when retreving this value i'm receiving the max value from balance instead of max date. So how could i call the balance value under max date value . Please help mew out i cant get it done...

 
Old May 8th, 2007, 01:04 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

The query you used is wrong. This will return independant max values of date and balance. You should use something like...
Code:
Select isnull(max(balance),0) from chinnamaniaccounts where date = ( Select max(date) from chinnamaniaccounts ) AND customerid=' ... ...
Hope that helps.
Cheers.

_________________________
- Vijay G
Strive for Perfection





Similar Threads
Thread Thread Starter Forum Replies Last Post
MAX/MIN Value Help slbibs SQL Server 2005 4 November 6th, 2007 04:00 AM
SQL script for selecting min and max values Nancy Krause Need help with your homework? 0 April 12th, 2007 11:29 AM
Max Date kristina Crystal Reports 1 July 10th, 2005 09:03 AM
How to get max value within same id jackps SQL Server 2000 1 January 20th, 2004 07:26 AM
How to select Max hosefo81 MySQL 0 November 25th, 2003 10:27 PM





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