Article View: borland.public.interbase.sql
Article #490group by cast datetime as integer?
From: RB Smissaert
Date: Tue, 18 Dec 2007 20:39
Date: Tue, 18 Dec 2007 20:39
32 lines
2012 bytes
2012 bytes
Trying to solve the following problem. I have quite a large table with 2 fields, a unique field with integer number, call this F1 and a field with datetime values, call this F2. Both fields will appear in ascending order when you do a select. F1 is indexed, but F2 is not. To show a small sample: F1 F2 -------------------------------------- 10303521 01/04/2006 19:50 10303525 01/04/2006 19:50 10303529 01/04/2006 19:50 10303535 01/04/2006 19:51 10303536 02/04/2006 07:43 <<< 10303540 02/04/2006 07:43 10303541 02/04/2006 07:43 10303546 02/04/2006 07:43 Now what I need to do is fetch all the rows that are the first row for the particular day, so in the above example I need the row indicated with <<< Now maybe I could do this with a GROUP BY and CAST(F2 AS INTEGER) but I can't work it out. Any suggestions how to tackle this? As this is a large table (over 20 million rows) and as F2 is not indexed maybe this will too slow in SQL and maybe I need an algorithm for this in my application. RBS
Technical Details
Message-ID:
<47682ff6$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 114a0e,87b0fc212a58b6a9,start X-Google-Attributes: gid114a0e,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: "RB Smissaert" <bartsmissaert@blueyonder.co.uk> Newsgroups: borland.public.interbase.sql Subject: group by cast datetime as integer? Date: Tue, 18 Dec 2007 20:39:04 -0000 Lines: 34 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.3138 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198 NNTP-Posting-Host: 82.37.28.137 Message-ID: <47682ff6$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1198010358 82.37.28.137 (18 Dec 2007 12:39:18 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail