Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Problem-Specific SQL Query

Author  Topic 

rahulmsccs
Starting Member

2 Posts

Posted - 2005-06-17 : 03:34:13

Hello Everyone,

Please get me the solution for the problem specified below:

Consider a table >

Column Name A B

23 g
26 m
23 h
55 a
26 k
23 s

I have to come up with a SQL query which can provide me with the output >

23 g, h, s
26 m, k
55 a

Regards,
Rahul

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-06-17 : 03:42:24
Refer this
http://sqlteam.com/item.asp?ItemID=2368

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

rahulmsccs
Starting Member

2 Posts

Posted - 2005-06-17 : 05:29:51
hey man ... thanx for the reply !

that was a good option.... but i hv' a small problem ! the page refers to a query >

DECLARE @EmployeeList varchar(100)

SELECT @EmployeeList = COALESCE(@EmployeeList + ', ', '') +
CAST(Emp_UniqueID AS varchar(5))
FROM SalesCallsEmployees
WHERE SalCal_UniqueID = 1

SELECT @EmployeeList

This query declares a variable - @EmployeeList
I want to code in Java so can't declare the variable. Also, I'm not allowed to implement this through stored procedure.
Can you suggest any solution for this ?

it wud b gr8 help !

Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-06-17 : 06:52:41
why can't you???

sSqlStmt = "DECLARE @EmployeeList varchar(100);
SELECT @EmployeeList = COALESCE(@EmployeeList + ', ', '') +
CAST(Emp_UniqueID AS varchar(5))
FROM SalesCallsEmployees
WHERE SalCal_UniqueID = 1;
SELECT @EmployeeList"

and then you execute that sSqlStmt with your JDBC or whatever you use.

Go with the flow & have fun! Else fight the flow
Go to Top of Page
   

- Advertisement -