Click here to Skip to main content
15,868,419 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have two columns in sqlserver in a table columns names are receiptno and amount.
if i have two receiptno's and amounts 200 and 300.now i want receiptno=2,3
and amount=500 how it can be possible.please help me as soon as possible
Posted

1 solution

Query:


SQL
SELECT  STUFF(
               (SELECT      ',' + Cast (recno as varchar(10))
               FROM     test
               FOR XML PATH('')), 1, 1, '') AS RecceiptNumbers,sum(amount) FROM test




My table structure
SQL
create table test
(recno int,
amount decimal)

INSERT INTO test VALUES (3,300)

SELECT  STUFF(
               (SELECT      ',' + Cast (recno as varchar(10))
               FROM     test
               FOR XML PATH('')), 1, 1, '') AS RecceiptNumbers,sum(amount) FROM test
 
Share this answer
 
v3
Comments
[no name] 1-Feb-13 0:40am    
@SANTOSH:THNX ALOT SIR
Santhosh Kumar Jayaraman 1-Feb-13 0:41am    
ya welcome

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900