Unix Technical Forum

Making First_value then second value in a recordset within case statement

This is a discussion on Making First_value then second value in a recordset within case statement within the Oracle Miscellaneous forums, part of the Oracle Database category; --> Experts i'm in desparate need please..using oracle 9.2 I have a case statement as such Code: (CASE WHEN a.field1= ...


Go Back   Unix Technical Forum > Database Server Software > Oracle Database > Oracle Miscellaneous

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-08-2008, 12:20 PM
MrHelpMe
 
Posts: n/a
Default Making First_value then second value in a recordset within case statement

Experts i'm in desparate need please..using oracle 9.2

I have a case statement as such
Code:
(CASE WHEN a.field1= first_value(a.field1 IGNORE NULLS) OVER
(Partition by a.field2 order by a.field3) and a.field4= 'WIP' and
a.field5 IN ('Homes', 'Autos') then 1
WHEN a.field1= first_value(a.field1 IGNORE NULLS) OVER
(Partition by a.field2 order by a.field3) and a.field4= 'WIP' and
a.field5 NOT IN ('Homes', 'Autos') then First_value = the value where
a.field5 = Homes or Autos and if this is true give this a 1
else 0 END) TEST
What I am trying to do is look at each record one at a time and based
on the recordset if the first value has a.field5 in Homes or auto then
examine that record and see if it meets all the rest of the criteria
that I put in my case statement and if it does then give me a 1. If
it doesn't keeping moving down the recordset for that a.field2 and
find the record that meets the criteria and make that the first value.
I am trying to ignore all records(not remove) that don't have the
appropriate field value. Is this possible? I do not want to remove
these records as I need to preform other case statements and all
records are needed.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-08-2008, 12:20 PM
dean
 
Posts: n/a
Default Re: Making First_value then second value in a recordset within case statement

On Feb 19, 7:13 pm, "MrHelpMe" <clintto...@hotmail.com> wrote:
> Experts i'm in desparate need please..using oracle 9.2
>
> I have a case statement as such
>
Code:
> (CASE WHEN a.field1= first_value(a.field1 IGNORE NULLS) OVER
> (Partition by a.field2 order by a.field3) and a.field4= 'WIP' and
> a.field5 IN ('Homes', 'Autos') then 1
>            WHEN a.field1= first_value(a.field1 IGNORE NULLS) OVER
> (Partition by a.field2 order by a.field3) and a.field4= 'WIP' and
> a.field5 NOT IN ('Homes', 'Autos') then First_value = the value where
> a.field5 = Homes or Autos and if this is true give this a 1
>         else 0 END) TEST
>
>
> What I am trying to do is look at each record one at a time and based
> on the recordset if the first value has a.field5 in Homes or auto then
> examine that record and see if it meets all the rest of the criteria
> that I put in my case statement and if it does then give me a 1. If
> it doesn't keeping moving down the recordset for that a.field2 and
> find the record that meets the criteria and make that the first value.
> I am trying to ignore all records(not remove) that don't have the
> appropriate field value. Is this possible? I do not want to remove
> these records as I need to preform other case statements and all
> records are needed.


Your question is a little muddled - what do you mean by " keeping
moving down the recordset for that a.field2 "? Please clarify.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-08-2008, 12:20 PM
MrHelpMe
 
Posts: n/a
Default Re: Making First_value then second value in a recordset within case statement

On Feb 20, 11:59 pm, "dean" <deanbrow...@yahoo.com> wrote:
> On Feb 19, 7:13 pm, "MrHelpMe" <clintto...@hotmail.com> wrote:
>
>
>
>
>
> > Experts i'm in desparate need please..using oracle 9.2

>
> > I have a case statement as such
> >
Code:
> > (CASE WHEN a.field1= first_value(a.field1 IGNORE NULLS) OVER
> > (Partition by a.field2 order by a.field3) and a.field4= 'WIP' and
> > a.field5 IN ('Homes', 'Autos') then 1
> >            WHEN a.field1= first_value(a.field1 IGNORE NULLS) OVER
> > (Partition by a.field2 order by a.field3) and a.field4= 'WIP' and
> > a.field5 NOT IN ('Homes', 'Autos') then First_value = the value where
> > a.field5 = Homes or Autos and if this is true give this a 1
> >         else 0 END) TEST
> >

>
> > What I am trying to do is look at each record one at a time and based
> > on the recordset if the first value has a.field5 in Homes or auto then
> > examine that record and see if it meets all the rest of the criteria
> > that I put in my case statement and if it does then give me a 1. If
> > it doesn't keeping moving down the recordset for that a.field2 and
> > find the record that meets the criteria and make that the first value.
> > I am trying to ignore all records(not remove) that don't have the
> > appropriate field value. Is this possible? I do not want to remove
> > these records as I need to preform other case statements and all
> > records are needed.

>
> Your question is a little muddled - what do you mean by " keeping
> moving down the recordset for that a.field2 "? Please clarify.- Hide quoted text -
>
> - Show quoted text -


Hey Dean,

Thanks for the feedback. I just figured it out. What I was trying to
do is find a position in recordset. I used the Rank() function and
accomplished what I needed. Thanks for the reply.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 07:19 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com