Unix Technical Forum

sql query

This is a discussion on sql query within the Oracle Miscellaneous forums, part of the Oracle Database category; --> hi ppl... i hav a table with MANY columns... A SAMPLE TABLE FOR MY QUERY WILL LOOK AS FOLL...... ...


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, 11:12 AM
Reiro
 
Posts: n/a
Default sql query

hi ppl...

i hav a table with MANY columns...
A SAMPLE TABLE FOR MY QUERY WILL LOOK AS FOLL......

NAME LEVEL ID

Jim P 1
Jim V 2
Peter P 3
Peter S 4
Peter E 5
Peter V 6


many records in the table follow this sequence with some having to
levels and some having four levels.


how can i write a query to display all with level 'E' (which is simple)
but also include the level 'P'. however i only want to display records
where the level 'P' has level V(refer to JIM)

so if i was to query this sample table .... my output would be as
follows...


NAME LEVEL ID

Jim P 1
Peter E 5


thx in advance

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-08-2008, 11:12 AM
Ed Prochak
 
Posts: n/a
Default Re: sql query


Reiro wrote:
> hi ppl...
>
> i hav a table with MANY columns...
> A SAMPLE TABLE FOR MY QUERY WILL LOOK AS FOLL......
>
> NAME LEVEL ID
>
> Jim P 1
> Jim V 2
> Peter P 3
> Peter S 4
> Peter E 5
> Peter V 6
>
>
> many records in the table follow this sequence with some having to
> levels and some having four levels.
>
>
> how can i write a query to display all with level 'E' (which is simple)
> but also include the level 'P'. however i only want to display records
> where the level 'P' has level V(refer to JIM)
>
> so if i was to query this sample table .... my output would be as
> follows...
>
>
> NAME LEVEL ID
>
> Jim P 1
> Peter E 5
>
>
> thx in advance


So what have you tried? While you are trying it yourself, consider
these hints:
* self join
* outer join

Can you build a query that returns all the rows that match the P with a
V criteria?

show us a sample of your code (ORACLE version is always helpful
information)

HTH,
ed

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-08-2008, 11:12 AM
Reiro
 
Posts: n/a
Default Re: sql query

hi i have found a way to find the P.... where there have a V and then
display all the E level's from the table....

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-08-2008, 11:12 AM
Ed Prochak
 
Posts: n/a
Default Re: sql query


Reiro wrote:
> hi i have found a way to find the P.... where there have a V and then
> display all the E level's from the table....


Care to post your solution?
ed

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-08-2008, 11:12 AM
Reiro
 
Posts: n/a
Default Re: sql query

My actual table has diff columns .. just sum of the columns needed for
my query are used.


select asset_id, content_title, asset_level
from asset_temp
where content_title not in
(select t.content_title from asset_temp t where t.asset_level =
'E') and
asset_level = 'P'
union
select asset_id, content_title, asset_level
from asset_temp
where asset_level = 'E'

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 12:21 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