RE: Please help with a SQL Query

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Still sounds like you need DISTINCT(accntid) and MAX(rechargedate) to me :-

SELECT
DISTINCT(accntid),RechargeDate,AmtBeforeRecharge,AmtAfterRecharge,RechargeAmt
,RechargeType, RechargedByNow, maxdate
FROM tablename
WHERE
maxdate = (SELECT MAX(RechargeDate) FROM tablename WHERE accntid = accntid)
ORDER BY accntid,RechargeDate

Not sure if this is exactly right, but should be close.

Rob.

-----Original Message-----
From: php-objects@xxxxxxxxxxxxxxx [mailto:php-objects@xxxxxxxxxxxxxxx] On
Behalf Of Ankit Mathur
Sent: 01 February 2008 07:48
To: php-objects@xxxxxxxxxxxxxxx
Subject: RE:  Please help with a SQL Query

Hi Friends, First of all I'm sorry for not being able to reply since my last
message. However, coming back to my query. 1. No. I don't want MAX of the
amount for each account but the latest entry even though it could be lesser
than earlier amounts. 2. I read in a mail where I was asked to supply other
columns also. Here's the list:Id, AcctId, RechargeDate, AmtBeforeRecharge,
AmtAfterRecharge, RechargeAmt, RechargeType, RechargedByNow to again put my
query in front of you guys.
I want only the latest entry of distinct accountids & not the rest of the
records 
Basically, records having MAX(RechargeDate) but one record only for one
AccountId.
I hope fellow members can help now.
 
Ankit Mathur


To: php-objects@xxxxxxxxxxxxxxxxxxx: cgrp@xxxxxxxxxxxxxxxx: Mon, 28 Jan 2008
20:19:04 +0100Subject: Re:  Please help with a SQL Query



In message
<C2C319C4C1CC7D46B2D7815BE3A2753E03CEC6B3@xxxxxxxxxxxxxxxxxxxxxxxxxxx>,
Atkinson, Robert <ratkinson@xxxxxxxxxxxxx> writes>I read it as he wants the
highest (MAX) amount from each account?>>Rob.Well, I didn't <G>Perhaps, if
(s)he is still around, maybe (s)he will let us know.-- Pete ClarkSunny
Andaluciahttp://hotcosta.com/Andalucia.Spain 






_________________________________________________________________
Post ads for free - to sell, rent or even buy.www.yello.in
http://ss1.richmedia.in/recurl.asp?pid=186

[Non-text portions of this message have been removed]



Are you looking for a PHP job? Join the PHP Professionals directory Now!
http://www.phpclasses.org/professionals/ 
Yahoo! Groups Links




***********************************************************************************
Any opinions expressed in email are those of the individual and not necessarily those of the company. This email and any files transmitted with it are confidential and solely for the use of the intended recipient 
or entity to whom they are addressed. It may contain material protected by attorney-client privilege. If you are not the intended recipient, or a person responsible for delivering to the intended recipient, be advised that you have received this email in error and that any use is strictly prohibited.

Random House Group + 44 (0) 20 7840 8400
http://www.randomhouse.co.uk
http://www.booksattransworld.co.uk 
http://www.kidsatrandomhouse.co.uk
Generic email address - enquiries@xxxxxxxxxxxxxxxxx

Name & Registered Office:
THE RANDOM HOUSE GROUP LIMITED
20 VAUXHALL BRIDGE ROAD
LONDON
SW1V 2SA
Random House Group Ltd is registered in the United Kingdom with company No. 00954009, VAT number 102838980
***********************************************************************************


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux