|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2005-10-10 : 07:41:48
|
| Rakhi writes "I am running SQL 7 and had a question about a SELECT statement I'm struggling with:DECLARE @CList varchar(1000)select o.orderdate, o.id,o.billtoname, o.grandtotal,(SELECT @Clist = (COALESCE(@CList + ', ', '') + CAST(ProductID AS nvarchar(5)))from vworderdetails where orderid = o.id)as ProductListfrom vworders ojoin vwcourseorders ocon o.id = oc.idwhere o.orderdate>='10/03/05'and o.orderdate<='10/07/05'order by o.orderdate descHere is the results I'm trying to retrieve:ORDERID, ORDERDATE, BILLTONAME, GRANDTOTAL, PRODUCTLIST---------------------------------------------------------1234, 10/04/05, John Doe, 1000.00, 681,682,683,6841235, 10/05/05, Jane Doe, 1500.00, 684,685,686,687,688..and so on...When I run the query above, I get an error at the stmt:SELECT @Clist = (COALESCE(@CList + ', ', '') + CAST(ProductID The error msg reads:Incorrect syntax near '='" |
|