| prasad |
Posted: Apr 05, 2007 12:56:24 AM |
Total Post: 35
Joined: Jan, 2007
|
solve this query
table x
=====
id name
= =====
1 a
2 b
3 c
1 d
4 h
2 i
1 j
3 k
1 l
7 e
2 f
the output shoud be
id name
= ====
1 a,d,j,l
2 b,i,f
3 c,k
4 h
7 e
|
|
|
sanju |
| Posted: Apr 05, 2007 02:29:21 AM | |
|
Total Post: 3
Joined: Mar, 2007
|
sir i have a student of mca. i have become dba. i have no idea of dba so please advice me . iam starting preparing to dba.
|
|
|
|
|
prasad |
| Posted: Apr 05, 2007 03:05:00 AM | |
|
Total Post: 35
Joined: Jan, 2007
|
Hi Sanju,
It's good thing that you want to be a DBA. but for that you have to work really very hard. Its not like .....completing a course for 2-3 months......and you will become a DBA.
I am just making you aware what it takes to be a DBA.
As a fresher you have to keep reading books, articles and at the same time you should constantly practice lots of SQL/PL SQL queries.
All the Best.
|
|
|
|
|
snehalatha |
| Posted: Apr 05, 2007 05:36:47 AM | |
|
Total Post: 169
Joined: Apr, 2006
|
In ORACLE COALESCE funtion is there for concatenating the similar things.
i am giving the sample (it's works fine in SQL SERVER) change the syntax according to ORACLE and try it. This function gives exactly what you want
CREATE function fnCreateCSVString
(
@id INT)
returns varchar(1000)
AS
BEGIN
DECLARE @sMyString varchar(1000)
select @sMyString = COALESCE(@sMyString + ',', ' ') + NAME from sample where id = @id
RETURN @sMyString
END
Select A.id,dbo.fncreatecsvstring(A.id) from
(Select distinct id from sample) A
|
|
|
|
|
busi |
| Posted: May 08, 2007 04:42:45 AM | |
|
Total Post: 13
Joined: Jan, 2007
|
I think it will work
SELECT deptno,
get_employees(deptno) AS employees
FROM emp
GROUP by deptno;
or
SELECT deptno, string_agg(ename) AS employees
FROM emp
GROUP BY deptno;
or
SELECT deptno,
tab_to_string(CAST(COLLECT(ename) AS t_varchar2_tab)) AS employees
FROM emp
GROUP BY deptno;
regards
busi
|
|
|
|
|
| Time Zone: EDT |
Send this thread to your friend |