SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


sql procedure


sql procedure

Author
Message
pallavi.unde
pallavi.unde
SSC Veteran
SSC Veteran (243 reputation)SSC Veteran (243 reputation)SSC Veteran (243 reputation)SSC Veteran (243 reputation)SSC Veteran (243 reputation)SSC Veteran (243 reputation)SSC Veteran (243 reputation)SSC Veteran (243 reputation)

Group: General Forum Members
Points: 243 Visits: 170
I want to display a various statements according to the condition through stored procedure like,

id_student=1 got below remark in subject
like

Id_student Id_subject grade
1 1 Good
1 2 Fair
1 3 Poor
1 4 Good
1 5 Fair
1 6 Poor

now i want to display a statements below,
for Good
Your performance is Good in 1,4
for Fair
Your performance is Fair in 2,5
for Poor
Your performance is Fair in 3,6



I am using mysql database please guide me how to show it ??

I need to show in below format
Id_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,6

please help me.

Thanks & Regards,
Pallavi
anthony.green
anthony.green
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10274 Visits: 6378
Hi

This 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


'Your performance is '+grade



I would do a google search for "MySQL string concat"



Want an answer fast? Try here
How to post data/code for the best help - Jeff Moden
When a question, really isn't a question - Jeff Smith
Need a string splitter, try this - Jeff Moden
How to post performance problems - Gail Shaw
CrossTabs-Part1 & Part2 - Jeff Moden
SQL Server Backup, Integrity Check, and Index and Statistics Maintenance - Ola Hallengren
Managing Transaction Logs - Gail Shaw
Troubleshooting SQL Server: A Guide for the Accidental DBA - Jonathan Kehayias and Ted Krueger


pallavi.unde
pallavi.unde
SSC Veteran
SSC Veteran (243 reputation)SSC Veteran (243 reputation)SSC Veteran (243 reputation)SSC Veteran (243 reputation)SSC Veteran (243 reputation)SSC Veteran (243 reputation)SSC Veteran (243 reputation)SSC Veteran (243 reputation)

Group: General Forum Members
Points: 243 Visits: 170
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,cogntion
and i used
'your perfomance is good in +' grade as u given it shows result 0 result.

Sad

Thanks & Regards,
Pallavi
anthony.green
anthony.green
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10274 Visits: 6378
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.



Want an answer fast? Try here
How to post data/code for the best help - Jeff Moden
When a question, really isn't a question - Jeff Smith
Need a string splitter, try this - Jeff Moden
How to post performance problems - Gail Shaw
CrossTabs-Part1 & Part2 - Jeff Moden
SQL Server Backup, Integrity Check, and Index and Statistics Maintenance - Ola Hallengren
Managing Transaction Logs - Gail Shaw
Troubleshooting SQL Server: A Guide for the Accidental DBA - Jonathan Kehayias and Ted Krueger


pallavi.unde
pallavi.unde
SSC Veteran
SSC Veteran (243 reputation)SSC Veteran (243 reputation)SSC Veteran (243 reputation)SSC Veteran (243 reputation)SSC Veteran (243 reputation)SSC Veteran (243 reputation)SSC Veteran (243 reputation)SSC Veteran (243 reputation)

Group: General Forum Members
Points: 243 Visits: 170
i want to concat row with comma separator and before that need to add one statement which is common ..

Thanks & Regards,
Pallavi
Bhuvnesh
Bhuvnesh
SSCertifiable
SSCertifiable (5.4K reputation)SSCertifiable (5.4K reputation)SSCertifiable (5.4K reputation)SSCertifiable (5.4K reputation)SSCertifiable (5.4K reputation)SSCertifiable (5.4K reputation)SSCertifiable (5.4K reputation)SSCertifiable (5.4K reputation)

Group: General Forum Members
Points: 5438 Visits: 4076
pallavi.unde (1/14/2013)
i want to concat row with comma separator and before that need to add one statement which is common ..
post the sample data with expected output

-------Bhuvnesh----------
I work only to learn Sql Server...though my company pays me for getting their stuff done;-)
Orlando Colamatteo
Orlando Colamatteo
SSCoach
SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)

Group: General Forum Members
Points: 15247 Visits: 14396
If you download this SQLCLR component...

http://groupconcat.codeplex.com/

...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.

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.x
GROUP BY Id_student,
grade;



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.

__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Ed Wagner
Ed Wagner
SSCoach
SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)

Group: General Forum Members
Points: 17027 Visits: 10089
In SQL Server, you could use the following:


SELECT 'Your performance is ' + CONVERT(Varchar, grade);



I would consult the MySQL documentation under "string concatenation" for details on how it's done in that database.


Tally Tables - Performance Personified
String Splitting with True Performance
Best practices on how to ask questions
Orlando Colamatteo
Orlando Colamatteo
SSCoach
SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)

Group: General Forum Members
Points: 15247 Visits: 14396
Ed Wagner (1/14/2013)
In SQL Server, you could use the following:


SELECT 'Your performance is ' + CONVERT(Varchar, grade);



I would consult the MySQL documentation under "string concatenation" for details on how it's done in that database.

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.

Your performance is Poor in 3,6


__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Ed Wagner
Ed Wagner
SSCoach
SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)

Group: General Forum Members
Points: 17027 Visits: 10089
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.


Tally Tables - Performance Personified
String Splitting with True Performance
Best practices on how to ask questions
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search