﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2008 / SQL Server Newbies  / sql procedure / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Mon, 20 May 2013 11:06:05 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: sql procedure</title><link>http://www.sqlservercentral.com/Forums/Topic1406633-1292-1.aspx</link><description>[quote][b]Ed Wagner (1/14/2013)[/b][hr][b]Now[/b] I see the trouble with what you were asking.  Does this give you what you're after?  It uses a correlated subquery [child] to concatenate the list for each row in [parent].  The [formatted] name is just for formatting it nicely and removing the trailing comma.  Since there was no table name in the original post, I used a temporary table named [#test], but you can change it however you like.[code="sql"]SELECT formatted.grade, LEFT(formatted.grade_id_list, LEN(formatted.grade_id_list) - 1)   FROM (SELECT DISTINCT parent.grade, (SELECT CONVERT (Varchar, child.id_grade) + ','                                          FROM #test child                                         WHERE child.grade = parent.grade                                         ORDER BY child.grade                                         FOR XML PATH ('')) grade_id_list          FROM #test parent) formatted  ORDER BY formatted.grade;[/code]I have no idea if this will work in MySQL at all.[/quote]Welcome! We are now on the same page.That is the XML PATH technique I alluded to in my earlier post. It is equivalent to using the SQLCLR object I linked to which attempts to provide a replacement for MySQL's GROUP_CONCAT on SQL Server.</description><pubDate>Mon, 14 Jan 2013 13:08:37 GMT</pubDate><dc:creator>opc.three</dc:creator></item><item><title>RE: sql procedure</title><link>http://www.sqlservercentral.com/Forums/Topic1406633-1292-1.aspx</link><description>[b]Now[/b] I see the trouble with what you were asking.  Does this give you what you're after?  It uses a correlated subquery [child] to concatenate the list for each row in [parent].  The [formatted] name is just for formatting it nicely and removing the trailing comma.  Since there was no table name in the original post, I used a temporary table named [#test], but you can change it however you like.[code="sql"]SELECT formatted.grade, LEFT(formatted.grade_id_list, LEN(formatted.grade_id_list) - 1)   FROM (SELECT DISTINCT parent.grade, (SELECT CONVERT (Varchar, child.id_grade) + ','                                          FROM #test child                                         WHERE child.grade = parent.grade                                         ORDER BY child.grade                                         FOR XML PATH ('')) grade_id_list          FROM #test parent) formatted  ORDER BY formatted.grade;[/code]I have no idea if this will work in MySQL at all.</description><pubDate>Mon, 14 Jan 2013 12:55:27 GMT</pubDate><dc:creator>Ed Wagner</dc:creator></item><item><title>RE: sql procedure</title><link>http://www.sqlservercentral.com/Forums/Topic1406633-1292-1.aspx</link><description>All you showed was the SELECT column list. Could you please provide the full query based on the test table I provided in an earlier post? I would like to see how you would get the grouping of the subject IDs for a particular student.</description><pubDate>Mon, 14 Jan 2013 12:24:19 GMT</pubDate><dc:creator>opc.three</dc:creator></item><item><title>RE: sql procedure</title><link>http://www.sqlservercentral.com/Forums/Topic1406633-1292-1.aspx</link><description>The fields can be concatenated together however they're needed.  I certainly don't claim to know MySQL at all - I was just offering a SELECT statement that would return what was needed.</description><pubDate>Mon, 14 Jan 2013 12:11:43 GMT</pubDate><dc:creator>Ed Wagner</dc:creator></item><item><title>RE: sql procedure</title><link>http://www.sqlservercentral.com/Forums/Topic1406633-1292-1.aspx</link><description>[quote][b]Ed Wagner (1/14/2013)[/b][hr]In SQL Server, you could use the following:[code="sql"]SELECT 'Your performance is ' + CONVERT(Varchar, grade);[/code]I would consult the MySQL documentation under "string concatenation" for details on how it's done in that database.[/quote]This problem goes a bit beyond simple string concatenation. Consider how you would display the list of subjects the student did poorly in, e.g.[quote]Your performance is Poor in 3,6[/quote]</description><pubDate>Mon, 14 Jan 2013 12:01:29 GMT</pubDate><dc:creator>opc.three</dc:creator></item><item><title>RE: sql procedure</title><link>http://www.sqlservercentral.com/Forums/Topic1406633-1292-1.aspx</link><description>In SQL Server, you could use the following:[code="sql"]SELECT 'Your performance is ' + CONVERT(Varchar, grade);[/code]I would consult the MySQL documentation under "string concatenation" for details on how it's done in that database.</description><pubDate>Mon, 14 Jan 2013 11:58:43 GMT</pubDate><dc:creator>Ed Wagner</dc:creator></item><item><title>RE: sql procedure</title><link>http://www.sqlservercentral.com/Forums/Topic1406633-1292-1.aspx</link><description>If you download this SQLCLR component...[u][url=http://groupconcat.codeplex.com/]http://groupconcat.codeplex.com/[/url][/u]...then you can write code like this in SQL Server very similar to what you would expect to be able to write in MySQL. Adding the ability to more easily port MySQL code to SQL Server is part of why I wrote the component.[code="sql"]CREATE TABLE dbo.x( Id_student INT, Id_subject INT, grade VARCHAR(10))INSERT  INTO dbo.x        (Id_student, Id_subject, grade)VALUES  (1, 1, 'Good'),        (1, 2, 'Fair'),        (1, 3, 'Poor'),        (1, 4, 'Good'),        (1, 5, 'Fair'),        (1, 6, 'Poor');SELECT  Id_student,        'Your performance is ' + grade + ' in ' + GroupConcatTest.dbo.group_concat(Id_subject) AS [Statement]FROM    dbo.xGROUP BY Id_student,        grade;[/code]There is an XML method as well. If you download group_concat check in the demo scripts for many comparable examples of using group_concat and the XML method.</description><pubDate>Mon, 14 Jan 2013 07:13:52 GMT</pubDate><dc:creator>opc.three</dc:creator></item><item><title>RE: sql procedure</title><link>http://www.sqlservercentral.com/Forums/Topic1406633-1292-1.aspx</link><description>[quote][b]pallavi.unde (1/14/2013)[/b][hr]i want to concat row with comma separator and before that need to add one statement which is common ..[/quote] post the sample data with expected output</description><pubDate>Mon, 14 Jan 2013 05:00:46 GMT</pubDate><dc:creator>Bhuvnesh</dc:creator></item><item><title>RE: sql procedure</title><link>http://www.sqlservercentral.com/Forums/Topic1406633-1292-1.aspx</link><description>i want to concat row with comma separator and before that need to add one statement which is common ..</description><pubDate>Mon, 14 Jan 2013 03:57:52 GMT</pubDate><dc:creator>pallavi.unde</dc:creator></item><item><title>RE: sql procedure</title><link>http://www.sqlservercentral.com/Forums/Topic1406633-1292-1.aspx</link><description>As I say, this is a MS SQL forum, not a MySQL forum, I do not know MySQL.The example I gave was for MS SQL, you will need to find the MySQL alternative or post the question on a MySQL forum.Group_Concat is not what you want, that will group the rows together and concatenate.</description><pubDate>Mon, 14 Jan 2013 03:51:15 GMT</pubDate><dc:creator>anthony.green</dc:creator></item><item><title>RE: sql procedure</title><link>http://www.sqlservercentral.com/Forums/Topic1406633-1292-1.aspx</link><description>Yes i need concatenation here i user group_concat function but ,select group_concat('your perfomance is good in',trait_name order by trait_name separator ',')but its showing your perfomance is good in numerical,'your perfomance is good in verbal,'your perfomance is good in cognition.which i dont want i need such'your perfomance is good in numerical,verbal,cogntionand i used 'your perfomance is good in +' grade as u given it shows result 0 result. :(</description><pubDate>Mon, 14 Jan 2013 03:46:25 GMT</pubDate><dc:creator>pallavi.unde</dc:creator></item><item><title>RE: sql procedure</title><link>http://www.sqlservercentral.com/Forums/Topic1406633-1292-1.aspx</link><description>HiThis is a Microsoft SQL server forum, not a MySQL forum.While a number of people here may have MySQL experience, you may be best posting this on a dedicated MySQL forum.But it looks like you want to do string concatination, which in T-SQL you can do by[code="sql"]'Your performance is '+grade[/code]I would do a google search for "MySQL string concat"</description><pubDate>Mon, 14 Jan 2013 03:37:29 GMT</pubDate><dc:creator>anthony.green</dc:creator></item><item><title>sql procedure</title><link>http://www.sqlservercentral.com/Forums/Topic1406633-1292-1.aspx</link><description>I want to display a various statements according to the condition through stored procedure like,id_student=1 got below remark in subjectlikeId_student	Id_subject	grade1	               1	Good1	               2	Fair1	               3	Poor1	               4	Good1	               5	Fair1	               6	Poornow i want to display a statements below,for Good Your performance is Good in 1,4for FairYour performance is Fair in 2,5for PoorYour performance is Fair in 3,6I am using mysql database please guide me how to show it ?? I need to show in below formatId_student  	Statement       1	        Your performance is Good in 1,4       1	        Your performance is Fair in 2,5       1	        Your performance is Fair in 3,6please help me.</description><pubDate>Mon, 14 Jan 2013 03:16:36 GMT</pubDate><dc:creator>pallavi.unde</dc:creator></item></channel></rss>