Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Query Question.
I did get my answer from this newgroup. I was told to use the decode
statement and it worked great.
select decode(sales_no, 1000,mike,2000,tim,3000,mary,sales_no)
Flipper wrote in message <70t5ca$us6$1_at_camel25.mindspring.com>...
>I am not clear as to exactly what you want to do but this would from what I
>understand you to be saying return what you wanted. You say that you would
>return multiple columns if what you meant is rows then this will not work
>for you.
>
>If this is just way to basic and I missed the point I appologize.
>
>Assuming you want to return the full name of all employees that are
assigned
>sales id number 123
>
>SELECT emp.first_name || " " || emp.last_name AS "sales_id"
>FROM employees emp, sales sale
>WHERE sale.sales_id = 123 AND
> emp.emp_id = sale.emp_id
>
>Would return:
>sales_id
>Barney Ruble
>Fred Flinstone
>
>Given many to one from sales to employees based on emp_id
>
>Sales
>sales_id emp_id
>123 456
>222 888
>123 999
>
>Employees
>emp_id first_name last_name
>456 fred flinstone
>999 barney ruble
>
>
>
>K Nez <"greater"@ spamless justviewit.com> > wrote in message
><6v8rel$4n2_at_sjx-ixn9.ix.netcom.com>...
>>I use Oracle 8, With Platinum's Forest and Trees as a development tool.
>>I am attempting to replace a columns results with an alias identifier.
>>Example: If a sales number show in a column I would like to replace it
>>with that salesperson's mame. In Forest and Trees I can use an IFVAL
>>function in the Select statement. But, if there are more than one
>>values (sales #s) it creates a new column for each. Then I have to go
>>through a bunch of hastle to joint all data back into a single colums..
>>Any suggestions.. Maybe Oracle could return what I need through the SQL
>>statement.
>>
>>Thanks
>
>
Received on Sat Oct 24 1998 - 19:12:37 CDT