Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: merging two rows
sunil(nani) wrote:
> Brian Peasland wrote:
>> sunil(nani) wrote: >>> can i merge two different rows into single row in a situations >>> where i can not use group by clause >>> >> I assume that since you referenced the GROUP BY clause, then you are >> talking about doing this in SQL. But I'm still not sure what you are >> attempting to do here. If you are using SQL, then why not use the GROUP >> BY clause? Do you care to provide a more specific example? >> >> Otherwise, there are methods to "merge" two rows into a single row in >> the result set. Many aggregate functions (MIN, MAX, etc) do just this >> and you are only required to use the GROUP BY clause when you are >> returning columns that will not participate in the aggregation. You can >> also "merge" two rows by doing a simple JOIN operation: >> >> SELECT t1.x, t2.x >> FROM table_x t1, tablex t2 >> WHERE t1.id = t2.id; >> >> HTH, >> Brian >> >> >> -- >> =================================================================== >> >> Brian Peasland >> dba_at_nospam.peasland.net >> http://www.peasland.net >> >> Remove the "nospam." from the email address to email me. >> >> >> "I can give it to you cheap, quick, and good. >> Now pick two out of the three" - Unknown
Use Brian's solution but assuming your column names are real also do this:
SELECT COUNT(*)
FROM gv$reserved_words
WHERE keyword IN ('ID', 'NAME', 'ACCOUNT', 'TYPE');
4 out of 4.
-- Daniel Morgan University of Washington Puget Sound Oracle Users GroupReceived on Wed Sep 27 2006 - 12:09:22 CDT
![]() |
![]() |