Subject RE: [Firebird-general] OT:Bye-bye SQL? (opinion)
Author Robert (Jamie) Munro
> -----Original Message-----
> From: Marius Popa Adrian [mailto:mapopa@...]
> Sent: 20 May 2003 13:29
> To: Firebird-general@yahoogroups.com
> Subject: [Firebird-general] OT:Bye-bye SQL? (opinion)
>
>
> http://www.silicon.com/opinion/500011-500001/1/4214.html
>
> For example, IBM has introduced more than 100 extensions to SQL
> just to support XML. And it is not limited to generic sets of
> extensions. There are also vendors including SQL extensions for
> specialised functions that SQL can't handle, such as time-lapsed
> queries (try asking a question such as "Who bought a barbecue
> within seven days of purchasing patio furniture?").

Table purchase:
person | item | date
-------+-----------+------------
1 | barbeque | 2003-05-10
1 | furniture | 2003-05-15

select barbeque.person, barbeque.date, furniture.date
from purchase as barbeque
inner join purchase as furniture on barebeque.person = furniture.person
where barebeque.item = 'barbeque' and furniture.item = 'furniture'
and barbeque.date < (furniture.date + 7) and furniture.date <
(barbeque.date + 7);

Any problems with the above? No specialised functions required. It might get
slow if a lot of people bought a lot of barbeques and furniture not within 7
days of each other.

How about:

select person from purchase where item = 'barbeque' and person in (select
person from purchase as purchase2 where purchase2.item = 'furniture' and
purchase2.date < (purchase.date + 7) and purchase.date < (purchase2.date +
7));

Might be quicker in some circumstances.

Robert Munro