🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.interbase.sql
Article #947

Re: actual(Date1) - next(Date2)

#947
From: Quinn Wildman (CodeGear Develope...
Date: Wed, 21 Mar 2007 22:12
17 lines
1880 bytes
Assuming you have InterBase 7.5 or 2007, created a calculated field 
using case, then order by that field. With earlier versions of InterBase 
you'll need a stored procedure that returns a results set and you can 
order on what it returns.

aleplgr wrote:
> asdfa
> I have one 3 field's table: ClientID, Date1 and Date2, first I need to order it  by ClientID and for each ClientID order by Date1, then: 
> I have to return a table with each CliendID and if the difference between the actual Date1 and next(Date2) >30 return actual Date1 else if there is no such difference >30 return the greatest Date1 for the actual ClientID. 
> 
> next(Date2) is the Date2 that is in the next row of the actual ClientID
> I can create auxiliar tables for storing intermmediate results and I'm using EMS SQL Manager 2005, but don't know how to deal with this, any hint please
> 

-- 
CREATE DOMAIN NEW_COMPANY AS CHAR(8) DEFAULT 'CODEGEAR' CHECK (VALUE <> 
'BORLAND') NOT NULL;
Technical Details
Message-ID: <4601ade7@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <4601ab4c$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 114a0e,dd90eb1b1157ce03
X-Google-Attributes: gid114a0e,public
X-Google-Language: ENGLISH,ASCII-7-bit
Date: Wed, 21 Mar 2007 15:12:54 -0700
From: "Quinn Wildman (CodeGear Developer Support)" <qwildman@nospam.codegear.com>
User-Agent: Thunderbird 1.5.0.10 (Windows/20070221)
MIME-Version: 1.0
Newsgroups: borland.public.interbase.sql
Subject: Re: actual(Date1) - next(Date2) 
References: <4601ab4c$1@newsgroups.borland.com>
In-Reply-To: <4601ab4c$1@newsgroups.borland.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 10.143.19.108
Message-ID: <4601ade7@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1174515175 10.143.19.108 (21 Mar 2007 15:12:55 -0800)
Lines: 17
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail