Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> Re: SQL question
> I am sorry I can't be more helpful. I don't really see this as problem, to
> me it's more of an exemple of bad data.
I am not sure if it is a bad data model. It's battle of normalization - denormalization.
I have a table Items. It's child is item_parts. Item can be made up of 1 or may parts. So it is right to store in a table like item_parts. okay?
Now if business asks give me the item that EXACTLY matches these parts - no more no less, its a valid question too.
Regards
Sandeep
On 1/13/06, Gleisson Henrique wrote:
> If you query like this:
>
> select *
> from foo
> where part = 'A'
>
> ITEM PA
> ---------- --
> 1 A
> 2 A
> 3 A
>
> The result set is correct because it matches exactly your condition. However
> you can do the following:
>
> select *
> from foo
> where part = 'A'
> and rownum < 2
>
>
> ITEM PA
> ---------- --
> 1 A
>
> But that's assuming the column item is in order, you won't be able to get
> item 2 if wanted to.
>
> I am sorry I can't be more helpful. I don't really see this as problem, to
> me it's more of an exemple of bad data.
>
> hope it helps tough
>
> gleisson henrique
>
>
> On 1/13/06, Sandeep Dubey wrote:
> >
> > Hi,
> >
> > I am having tough time writing a select query. I won't blame it on
> > Friday afternoon, it is really difficult to me.
> >
> > Here is an example:
> >
> > create table foo ( item number, part varchar2(2));
> >
> > insert into foo values(1,'A');
> > insert into foo values(2,'A');
> > insert into foo values(2,'B');
> > insert into foo values(3,'A');
> > insert into foo values(3,'B');
> > insert into foo values(3,'C');
> >
> > I want to query for item that matches exact parts given in the query.
> > i.e.if I query for part A, I should get 1 ( no 2 and 3)
> >
> > If I pass A and B , I should get only 2 (no 3)
> > If I query for A, B and C, I should get only 3.
> >
> > Query can have n number of parts, It should return only that item that
> > has exact match to parts, no less no more.
> >
> > Thanks
> >
> >
> > Sandeep
> > --
> > http://www.freelists.org/webpage/oracle-l
> >
> >
> >
>
>
-- http://www.freelists.org/webpage/oracle-lReceived on Fri Jan 13 2006 - 20:59:17 CST
![]() |
![]() |