Re: Please help with a SQL Query

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

 



Hi Mathur

The simplest way (but may not be efficient w.r.to memory!!) is to add a new column in the table, e.g. addTrack (initially 1 for the first entry to the table). It will increase by 1 every time you add a record. So, the last record will have the highest (or MAX) value for addTrack. Hope it will work. There several other ways to do it. But this is the simplest with a very low increase in memory (but still uses memory!!). There may be tricks to do it without extra column if you could define the Id to stick to the increment rule in anyway. MAX(recheargeDate) will not work when in the same date you have many entries (at least 2). You may add recheargeTime also, then you can work with both the date and time. But it may require some logical coding!

Best wish.
Masud


----- Original Message ----
From: Ankit Mathur <ankitmathur82@xxxxxxxxxxx>
To: php-objects@xxxxxxxxxxxxxxx
Sent: Friday, February 1, 2008 2:48:18 PM
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@ yahoogroups. comFrom: cgrp@hotcosta. comDate: Mon, 28 Jan 2008 20:19:04 +0100Subject: Re:  Please help with a SQL Query

In message <C2C319C4C1CC7D46B2D 7815BE3A2753E03C EC6B3@coxsrv- 3.uk.randomhouse .com>, Atkinson, Robert <ratkinson@tbs- ltd.co.uk> 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.richmedi a.in/recurl. asp?pid=186

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





      ____________________________________________________________________________________
Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ 


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


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

  Powered by Linux