Subject RE: [firebird-support] data retrieval
Author Alan McDonald
> We're looking to get all fields for the records that match the criteria.

so you want to ignore all columns of data where the col1 and col2 values are
re-iterated?
so col4, 5, 6, etc of data is meaningless? why keep it? why not constrain
the data to unique col2, col3 values?
How do you decide that the second and third etc occurrences of col1, col2
records have meaningless values in their col4, col5 etc fields?

anyway - a clumsy way is
a view on distinct col1, col2

try
select col1, col2,
(select first 1 col3 from table where table.col1=view.col1 and
tablecol2=view.col2 order by table.rec#)
(select first 1 col4 from table where table.col1=view.col1 and
tablecol2=view.col2 order by table.rec#)
from view

>
>
>
> -----Original Message-----
> From: firebird-support@yahoogroups.com
> [mailto:firebird-support@yahoogroups.com] On Behalf Of Nick Upson
> Sent: Thursday, April 12, 2007 8:49 AM
> To: firebird-support@yahoogroups.com
> Subject: Re: [firebird-support] data retrieval
>
>
>
> you can get the required values by
>
> select col1, col2 from table1
> group by col1, col2
> having count(*) = 1
>
> or
>
> select distinct col1, col2 from table1
>
> for the other parts of the records like rec# the problem is which one
> do you want?
>
> On 12/04/07, Peter Turner <PeterTurner@...
> <mailto:PeterTurner%40sunnuclear.com> > wrote:
> > Mis-typed what we wanted.....meant we wanted rec #1, #2, #4, #5, #6,
> and
> > #7 - skipping #3 and #8
> >
> >
> >
> > pbt.
> >
> >
> >
> > -----Original Message-----
> > From: firebird-support@yahoogroups.com
> <mailto:firebird-support%40yahoogroups.com>
> > [mailto:firebird-support@yahoogroups.com
> <mailto:firebird-support%40yahoogroups.com> ] On Behalf Of Alan McDonald
> > Sent: Wednesday, April 11, 2007 5:38 PM
> > To: firebird-support@yahoogroups.com
> <mailto:firebird-support%40yahoogroups.com>
> > Subject: RE: [firebird-support] data retrieval
> >
> >
> >
> > > hi,
> > >
> > > have a table with the following conceptual data...
> > > rec# col1 col2 ... coln
> > > 1 1 d data
> > > 2 1 m data
> > > 3 1 d data
> > > 4 2 d data
> > > 5 2 m data
> > > 6 3 d data
> > > 7 3 m data
> > > 8 3 d data
> > >
> > > trying to come up with a single query that would return unique
> records
> >
> > > where the combination of col1 and col2 are unique. in the example,
> > > would want rec #1, #2, #3, #4, #6, and #7.
> > >
> > > have come up with a couple of multiple query ideas, but was
> wondering
> > > how to do this in a single query (if possible).
> > >
> > > TIA,
> > >
> > > Pete Turner
> > > Sun Nuclear Corp.
> >
> > but #5 is unique too no?
> > Alan
> > try a view on ditinct col1, col2
> > then join the other data to the view
> > Alan
> >
> >
> >
> >
> >
> > [Non-text portions of this message have been removed]
> >
> >
> >
> > ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> >
> > Visit http://www.firebirdsql.org <http://www.firebirdsql.org> and
> click the Resources item
> > on the main (top) menu. Try Knowledgebase and FAQ links !
> >
> > Also search the knowledgebases at http://www.ibphoenix.com
> <http://www.ibphoenix.com>
> >
> > ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
>
>
>
>
>
> [Non-text portions of this message have been removed]
>
>
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Visit http://www.firebirdsql.org and click the Resources item
> on the main (top) menu. Try Knowledgebase and FAQ links !
>
> Also search the knowledgebases at http://www.ibphoenix.com
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Yahoo! Groups Links
>
>
>
>