Subject | Re: Select last - How to select latest data |
---|---|
Author | Svein Erling Tysvær |
Post date | 2005-12-09T08:00:13Z |
--- In firebird-support@yahoogroups.com, "menjit_singh" wrote:
you should consider his advice and take a few hours off the computer
and play some football or similar with him and if he is 35 like me,
well, then he's either got a strange sense of humour or you've got a
potential problem that this list probably cannot solve.
'SELECT D1.CLS, D1.VOL, D1.OPN,
D1.HIGH, D1.LOW, D1.DATA, D1.symbol FROM DATA D1
WHERE D1.STOCK='''+imya+''' AND
D1.DATA >= (SELECT MAX(D2.DATA) - 30 FROM DATA D2
WHERE D2.STOCK='''+imya+''')
order by D1.DATA'
and have a descending index for DATA?
(or use parameters as Helen suggested, that is at least as good a
suggestion. By the way, Helen, in Russian imya simply means 'name' and
if this is part of a statement in Delphi, then he simply wants STOCK
to equal the content of his variable IMYA).
Alan is correct in that using COUNT is slow if the count is huge,
though it only matters if you add more data to your table for the same
STOCK.
HTH,
Set
> Sorry about the empty reply, my son keep pressing the mouse...If he's less than 10 years old that's fine, if he is a teenager, maybe
you should consider his advice and take a few hours off the computer
and play some football or similar with him and if he is 35 like me,
well, then he's either got a strange sense of humour or you've got a
potential problem that this list probably cannot solve.
> I used method 1 as you have told, double ((__)) and ASC. the error iStrange...
> got is 'Access Violation at address 00404BBA...'
> The reason i need the latest 30 days data is because the stockNow, this sounds different. What about
> information is not upto date (eg is not up today's date). some stock
> data are 5 days old, 10 days and some 30 days old.
'SELECT D1.CLS, D1.VOL, D1.OPN,
D1.HIGH, D1.LOW, D1.DATA, D1.symbol FROM DATA D1
WHERE D1.STOCK='''+imya+''' AND
D1.DATA >= (SELECT MAX(D2.DATA) - 30 FROM DATA D2
WHERE D2.STOCK='''+imya+''')
order by D1.DATA'
and have a descending index for DATA?
(or use parameters as Helen suggested, that is at least as good a
suggestion. By the way, Helen, in Russian imya simply means 'name' and
if this is part of a statement in Delphi, then he simply wants STOCK
to equal the content of his variable IMYA).
Alan is correct in that using COUNT is slow if the count is huge,
though it only matters if you add more data to your table for the same
STOCK.
HTH,
Set