Subject Re: [firebird-support] Need some SQL help
Author Helen Borrie
At 01:49 PM 5/09/2003 +0300, you wrote:
>I have table called STATEMENTS where I have among other things 2 columns:
> SDATE DATE,
> OPTYPE VARCHAR(3)
>
>SDATE contains dates and OPTYPE contains various operation types and 2
>specific values - 'OB' (opening balance) and 'CB' (closing balance). For
>each 'OB' value there must be also 'CB'. For each day there may be more
>than one pair.
>
>I want to check if there exists some orphan 'OB' or 'CB' values and
>rtrieve the dates of these cases. As my SQL knowledge is limited to SELECT
>* FROM xxx :-) , I need some help.
>
>Is it possible to get the info with one SQL sentence?

Because of the possibility of dup records and not knowing whether you are
looking for one or both values missing, I think you'll need to get all of
the columns, not just the date.

select * from statements
where ob is null or cb is null

heLen