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 |
rintus
Starting Member
26 Posts |
Posted - 2008-09-18 : 12:03:04
|
I want to know what do I do to get the the first two characters of each subjects. I mean if a student is steve and he takes two courses say maths and science. What changes do I need to make to this SQL to get the output as - Student_Name PrefixSteve MaSteve ScPlease helpselect distinct a.name Student_name, count(b.subj)from student a,subject b where b.rod_id = a.row_idgroup by a.nameorder by 1 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-09-18 : 12:35:42
|
no need of groupingselect a.name as Student_name,left(b.subj,2) AS Prefixfrom student a,subject b where b.rod_id = a.row_id |
 |
|
rintus
Starting Member
26 Posts |
Posted - 2008-09-18 : 13:13:19
|
Thanks man, u r amazing |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-09-18 : 13:17:54
|
quote: Originally posted by rintus Thanks man, u r amazing
you're welcome |
 |
|
|
|
|