Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


how to get enames with comma seperated values by deptwise
on emp table?

Answers were Sorted based on User's Feedback



how to get enames with comma seperated values by deptwise on emp table?..

Answer / kavitha nedigunta

SELECT deptno, wm_concat(ename) AS EMP_STRING
FROM emp
GROUP BY deptno;

works in 10g

Is This Answer Correct ?    6 Yes 0 No

how to get enames with comma seperated values by deptwise on emp table?..

Answer / kavitha nedigunta

SELECT deptno ,
LTRIM(MAX( SYS_CONNECT_BY_PATH (
ename, ',')),',') EMP_STRING
FROM
(SELECT empno , ename, deptno,
row_number() OVER ( PARTITION BY deptno ORDER
BY rownum) rn
FROM EMP )
CONNECT BY deptno = PRIOR deptno
AND rn = PRIOR rn+1
START WITH rn =1
GROUP BY deptno
ORDER BY deptno;

Is This Answer Correct ?    5 Yes 0 No

how to get enames with comma seperated values by deptwise on emp table?..

Answer / amitabha mandal

COLUMN employees FORMAT A50

SELECT deptno, wm_concat(ename) AS employees
FROM emp
GROUP BY deptno;

DEPTNO EMPLOYEES
---------- -------------------------------------------------
-
10 CLARK,KING,MILLER
20 SMITH,FORD,ADAMS,SCOTT,JONES
30 ALLEN,BLAKE,MARTIN,TURNER,JAMES,WARD

3 rows selected.

check tyhis link :http://www.oracle-
base.com/articles/misc/StringAggregationTechniques.php

Is This Answer Correct ?    3 Yes 0 No

how to get enames with comma seperated values by deptwise on emp table?..

Answer / ramesh

select deptno,listagg(ename,',') within group(order by sal)
from emp group by deptno;

NOTE:IT IS WORKING ONLY 11G IF YOU ARE INSTALLING IN YOUR SYSTEM TRY IT GUYS

Is This Answer Correct ?    1 Yes 0 No

how to get enames with comma seperated values by deptwise on emp table?..

Answer / g

SELECT DEPT.DEPT_ID,LIST_AGG(E.EMP_NAME) FROM EMP E,DEPT D WHERE E.DEPT_ID=DEPT.DEPT_ID GROUP BY DEPT.DEPT_ID;

Is This Answer Correct ?    0 Yes 0 No

how to get enames with comma seperated values by deptwise on emp table?..

Answer / gj

SELECT deptno, LIST_AGG(ename) AS EMP_STRING
FROM emp
GROUP BY deptno;

Is This Answer Correct ?    0 Yes 0 No

how to get enames with comma seperated values by deptwise on emp table?..

Answer / pradeep

select deptno,cursor (select ename ,deptno from emp where
d.deptno = deptno ) from dept d

1* select deptno,cursor (select
SQL> /

DEPTNO CURSOR(SELECTENAME,D
---------- --------------------
10 CURSOR STATEMENT : 2

CURSOR STATEMENT : 2

ENAME DEPTNO
---------- ----------
CLARK 10
KING 10
MILLER 10

20 CURSOR STATEMENT : 2

CURSOR STATEMENT : 2

ENAME DEPTNO
---------- ----------
PORT NO 20
SMITH 20
JONES 20
SCOTT 20
ADAMS 20
FORD 20

6 rows selected.

30 CURSOR STATEMENT : 2

CURSOR STATEMENT : 2

ENAME DEPTNO
---------- ----------
ALLEN 30
WARD 30
MARTIN 30
BLAKE 30
TURNER 30
JAMES 30

6 rows selected.

40 CURSOR STATEMENT : 2

CURSOR STATEMENT : 2

no rows selected

Is This Answer Correct ?    0 Yes 1 No

how to get enames with comma seperated values by deptwise on emp table?..

Answer / rasmita basantia

select ename ||' , '||deptno from emp order by deptno

Is This Answer Correct ?    4 Yes 7 No

Post New Answer

More SQL PLSQL Interview Questions

what are the t string functions available in tsql? : Transact sql

0 Answers  


How to display Row Number with Records in Oracle SQL Plus?

0 Answers   MCN Solutions,


How do you pronounce sql?

0 Answers  


sql query to get zero records from a table having n no of records

8 Answers   CTS,


what are the difference between clustered and a non-clustered index? : Sql dba

0 Answers  


What happens if a procedure that updates a column of table X is called in a database trigger of the same table ?

1 Answers  


ename empno deptno amar 1 10 akbar 2 20 anthonny 3 30 jonathan 4 40 write a procedure to dispaly the column values ina row separated by a deleimiter eg - input - select ename from emp '|' output - amar|akbar|anthony|jonathan input - select empno from emp '@' o/p - 1@2@3@4 input - select deptno from emp '/' o/p - 10/20/30/40 Pls answer this questn.

2 Answers  


How can you select unique records from a table?

0 Answers  


What does an inner join do?

0 Answers  


what is SCALAR Queries?

2 Answers   ITC Infotech,


How to check if a column is nullable before setting to nullable?

0 Answers  


What is sqlerrd?

0 Answers  


Categories