All Questions

289
votes
9answers
151086 views

Simulating group_concat MySQL function in Microsoft SQL Server 2005?

I'm trying to migrate a MySQL-based app over to Microsoft SQL Server 2005 (not by choice, but that's life). In the original app, we used almost entirely ANSI-SQL compliant statements, with one signif...
269
votes
16answers
357151 views

How to use GROUP BY to concatenate strings in SQL Server?

How do I get: id Name Value 1 A 4 1 B 8 2 C 9 to id Column 1 A:4, B:8 2 C:9
67
votes
4answers
115438 views

How to make a query with group_concat in sql server

I know that in sql server we cannot use Group_concat function but here is one issue i have in which i need to Group_Concat my query.I google it found some logic but not able to correct it.My sql query...
16
votes
2answers
5571 views

SQL Query to get aggregated result in comma seperators along with group by column in SQL Server

I need to write a sql query on the table such that the result would have the group by column along with the aggregated column with comma separators. My table would be in the below format |```````...
67
votes
1answers
215525 views

Multiple rows to one comma-separated value

I want to create a table valued function in SQL Server, which I want to return data in comma separated values. For example table: tbl ID | Value ---+------- 1 | 100 1 | 200 1 | 300 1 | 400 ...
14
votes
3answers
25812 views

SQL comma-separated row with Group By clause

I have the following query: SELECT Account, Unit, SUM(state_fee), Code FROM tblMta WHERE MTA.Id = '123' GROUP BY Account,Unit This of course throws an exception because the Code is not in t...
23
votes
7answers
67609 views

SQL, How to Concatenate results?

I currently have a SQL query that returns a number of fields. I need one f the fields to be effectively a sub query sub that. The Problem in detail: If I have a table X with two columns, ModuleID...
4
votes
3answers
1212 views

SQL same unit between two tables needs order numbers in 1 cell

I have 2 tables: SELECT UnitId FROM dbo.tblUnits SELECT UnitId, WorkOrderNumber FROM dbo.tblWorkOrders I need to display all UnitId's from dbo.tblUnits then in 1 column diplay all the WorkOrders s...
20
votes
4answers
34051 views

How to concatenate all strings from a certain column for each group

Suppose I have this table [Table1] Name Mark ------- ------ ABC 10 DEF 10 GHI 10 JKL 20 MNO 20 PQR 30 What should be my SQL statement to retrieve a record that looks like...
1
votes
2answers
526 views

Concatenate multiple rows

I'm using Microsoft SQL Server 2005. I think I need a sub-query. I'm looking for one (1) row per customer, with the AvailableAction field be a concatenation of all the Actions for each customer. us...

Previous Next