return records based on records [message #668861] |
Mon, 19 March 2018 11:42 |
|
mist598
Messages: 1195 Registered: February 2013 Location: Hyderabad
|
Senior Member |
|
|
Hi All,
I have a data like below and need to return rows based on the cost_type.
select 'Item111' item1, 'Frozen' cost_type from dual
union all
select 'Item111' item1, 'Pending' cost_type from dual
select 'Item123' item1, 'Frozen' cost_type from dual
union all
select 'Item123' item1, 'Frozen' from dual
If the Item111 cost_type is in Frozen and Pending then i need pending records.
If the Item123 cost_type is in Frozen only then return all the records.
Please let me know if any questions
|
|
|
|
|
|
|
Re: return records based on records [message #668890 is a reply to message #668867] |
Tue, 20 March 2018 14:20 |
|
Barbara Boehmer
Messages: 9097 Registered: November 2002 Location: California, USA
|
Senior Member |
|
|
Michel Cadot wrote on Mon, 19 March 2018 23:00
Where does the condition "If the Item123 cost_type is in Frozen only then return all the records." come into play in your query?
I surmised that it meant all records for that item number, if there are only frozen records for that item, no pending records, assuming that frozen and pending are the only values, as in the sample data. It looks like the o.p. may be looking for each item, if there are any pending records, then only pending records for that item, but if there are no pending records for that item, then all of the records for that item. This assumes there are only pending and frozen values, as in the example data. My guesses may or may not be correct. I figured I would offer it along with the other suggestions and wait and see what the response is.
[Updated on: Tue, 20 March 2018 14:21] Report message to a moderator
|
|
|