Re: Help with SQL/report
Posted in 1998
{ How about this: }
create temp table
lithology ( official_name char(5) ,
top_depth real ,
bottom_depth real ,
lith_type char(4) ) with no log ;
{ ... I made official_name a char(5) instead of an integer,
the better to accomodate the value 'WELL1'... and I
made lith_type a char(4), I forget exacxtly why. }
insert into lithology values ( 'WELL1', 0.0, 6.0, 'SD' ) ;
insert into lithology values ( 'WELL1', 6.0, 7.5, 'ML' ) ;
insert into lithology values ( 'WELL1', 7.25, 9.0, 'CL' ) ;
insert into lithology values ( 'WELL1', 9.0, 14.0, 'SD' ) ;
select l1.official_name o_name,
l1.top_depth tp1, l1.bottom_depth bd1, l1.lith_type lt1,
l2.top_depth td2, l2.bottom_depth bd2, l2.lith_type lt2
from lithology l1, lithology l2
where l1.official_name = l2.official_name
and l2.top_depth >= l1.top_depth
and l2.top_depth < l1.bottom_depth
and l1.lith_type != l2.lith_type
{ which returns the following:
o_name tp1 bd1 lt1 td2 bd2 lt2
WELL1 6.00 7.50 ML 7.25 9.00 CL
Will that do the job, do you think?
- Paul (just lil ol' me, not a spokesman, etc) }