Questions tagged [sql-server-group-concat]

In MySQL GROUP_CONCAT functionality is comma separated values grouped by a defined key.

In MySQL GROUP_CONCAT functionality is comma separated values grouped by a defined key.

62 questions
1
vote
2 answers

How to return one row but concatenate the reason column

I have an sql server 2012 database table which contains data just like below: id import_id tenancyname owner reason ----- ---------- ------------ ----- ------ 1 1 test null Owner is missing 2 2 …
Stew
  • 305
  • 2
  • 5
  • 14
1
vote
2 answers

Concatenate columns in Pivot View

DECLARE @DynamicPivotQuery AS NVARCHAR(MAX) DECLARE @ColumnName AS NVARCHAR(MAX) --Get distinct values of the PIVOT Column SELECT @ColumnName= ISNULL(@ColumnName + ',','') + QUOTENAME(ACT_DESC) FROM (SELECT DISTINCT ACT_DESC FROM tpc) AS…
1
vote
1 answer

Need Correct Format for CONCAT sql query. Codeigniter Active Record

I am using codeigniter's active record, but i've realized I probably need a regular SQL query for what I'm trying to accomplish. Could someone please look at this code and give me the correct format. What am I doing wrong here? I think it's obvious…
1
vote
3 answers

SQL Query to produces Comma Seperated Column from redundent Rows?

I have two table, which are joined together and stored in a temp table. The Temp table consist the data in following form: |ID|Name |Code| |1 | 100 |AAAA| |1 | 100 |AAAB| |1 | 100 |AAAA| |2 | 200 |AAAZ| more... Now I want the outcome in the…
1
vote
1 answer

Aggregate function to concatenate strings joining two tables?

I know how to concatenate fields on aggregate query using for xml auto. But I've some problems to extend that query to use with two tables, the following example does not work E.g. set nocount on; declare @FirstTable table (RowID int, LinkedField…
FDB
  • 971
  • 16
  • 32
1
vote
1 answer

how to fetch multiple record by stored procedure

select t.Sno, t.childid, (select customername as n from customerprofile c where c.cusid = t.childid) as name,t.earnedmoney as commission, (select p.bookingamt from propertyregistration p, customerprofile c where p.applicationno =…
1
vote
2 answers

SQL Select Query - Conversion Error

Hi I am trying below query. Where output of ProjectID is 1,2,3. I am trying to fetch data using ProjectID from other table. DECLARE @ProjectID varchar(100) DECLARE @ImpactIntakeID varchar(100) set @ProjectID = (SELECT STUFF ((SELECT ',' +…
sk7730
  • 636
  • 3
  • 9
  • 32
1
vote
2 answers

MSSQL - Concat the result of a query using IN

In a MSSQL table ("username"), I have the two following records: name ¦ nickname John Johny Marc Marco I'd like to do a query that would return "Johny, Marco" when I as k for the nicknames of John and Marc. I've tried the…
0
votes
1 answer

How to Query Data with Specified Multiple Field Values?

I have a table as follows: Id = stretch(1..100,1000) area = take(`A`B`C`D`E`F`G`H`I`J,1000) qyt = rand(100.00,1000) t = table(Id,area,qyt) I want to query data with multiple field values. Query condition: field value “Id=1“, “area“ = A, F,…
0
votes
1 answer

Subquery returning csv written values in a Main Query Column, possible?

I got to tables. TABLE 1: [..fields..] [CATEGORIE] [..fields..] TABLE 2: [..fields..] [ID] [CATEGORIE] [..fields..] I want to connect a bit special and tried it like this: SELECT [..other fields..], CATEGORIE, (SELECT ID FROM TABLE2 WHERE…
Harry
  • 1,313
  • 3
  • 22
  • 37
0
votes
1 answer

How do you order the results of mySQL group_concat() when all the values come from one column?

I have a simple table that has 3 columns: id, variable, and value. There are a lot of user IDs and a lot of different variables per person too (all the specs from their profiles to be exact), but I only need to query one person at a time with…
thirtywest
  • 13
  • 5
0
votes
1 answer

MYSQL - Concatenating two group concat functions into a list

So i'm working with this data set based on a sneaker store, and what i need to do, is to get rid of duplicate fields containing shoe models that only differ in size. What i'm trying to do, is to merge the columns that contain seperately the size and…
0
votes
2 answers

Group by with comma-separated values and excluding the value from the previous column value

I have two tables Lecturer and Student and I would like to display the other lecturer id's in the new column with comma separated values. I am using SQL Server 2014. Table: Lecturer id name subject ------------------------------- 102 …
0
votes
2 answers

How to use GROUP_CONCAT on multiple JOIN

I am currently retrieving data from multiple tables using a cus_id as the initial query. From here I have multiple tables that can have various rows of data that I would like to retrieve and use GROUP_CONCAT to return this data in a single row. At…
Eric M
  • 23
  • 7
0
votes
1 answer

GROUP_CONCAT in SQL Server error

Error:Column 'ReviewConsultants.ConsultantID' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause. Query: select R.ReviewID, STUFF((select distinct ',' + FirstName …
sai
  • 1
  • 4