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.
| Author |
Topic |
|
mldardy
Starting Member
13 Posts |
Posted - 2009-06-22 : 20:28:14
|
| In the query below, I am trying to show the customer once for each rate code. Meaning there is 1 customer but they may have 15 rate codes for example. The problem now is on the GROUP BY I get an error that asks for the dratecode to be included in the GROUP BY.How do I fix this query so when I run it shows the the customer one time with each dratecode in a concatenated string separated by commas. SELECT a.HOUSE, a.ACCTCORP, a.CUST, { fn CONCAT(b.DRATECODE, ',') } AS Expr1FROM CUST_TABLE a INNER JOIN RC_TABLE b ON a.ACCTCORP = b.ACCTCORPGROUP BY a.HOUSE, a.ACCTCORP, a.CUST,ORDER BY a.HOUSE DESC |
|
|
masoudsafi
Starting Member
2 Posts |
Posted - 2009-06-22 : 20:40:48
|
| try this:SELECT DISTINCT ACCTCORP FROM RC_TABLEThen you can do an inner join to your CUST_TABLE to obtain additional columns that you need. If you are using SQL 2005 Management Studio, you may want to use the Query Designer.Good luck. |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
|
|
|
|
|