| Author |
Topic |
|
ZkInPhamouS
Starting Member
5 Posts |
Posted - 2012-03-12 : 14:12:12
|
| Hi all,I'm trying to sort a column and group it in certain way.. basically, this is my situation.I ORDERED BY column B in an ASC order, however, within that column I also need to group say... "all the X001" together and "all the Y012" together.Right now the format is like...Column BThe High Impact Axe X001The High Impact Drill Y012The High Impact Hammer X001The Low Impact Axe X001The Low Impact Drill Y012you see, the names are in ASC order, but at the same time, I also need to group all the X001s and Y012 together.Any suggestions?Thanks! |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2012-03-12 : 14:37:09
|
order by right(ColumnB,4),ColumnB No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
ZkInPhamouS
Starting Member
5 Posts |
Posted - 2012-03-12 : 14:45:15
|
| Thanks!but I forgot to mention that at the end, it isn't so predictable, it's more like X001 - xsuagejakeY012 -iryhanldjiljaj |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-03-12 : 15:11:35
|
quote: Originally posted by ZkInPhamouS Thanks!but I forgot to mention that at the end, it isn't so predictable, it's more like X001 - xsuagejakeY012 -iryhanldjiljaj
so you need to consider whole of it or just the X001,Y012 part alone? also will the format be always consistent?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
ZkInPhamouS
Starting Member
5 Posts |
Posted - 2012-03-12 : 15:21:56
|
quote: Originally posted by visakh16
quote: Originally posted by ZkInPhamouS Thanks!but I forgot to mention that at the end, it isn't so predictable, it's more like X001 - xsuagejakeY012 -iryhanldjiljaj
so you need to consider whole of it or just the X001,Y012 part alone? also will the format be always consistent?
Just X001 and Y012 part alone, but the format is not always consistent. It will be like:Column: Data Testabcd: X001 - qwertyyuxyz:X001 - asdfghjklbnmas: Y012 - zxdfvghnxbsjew :X001 - rhjshjkfakdj: Y012 - jfsdklfjksdjfksdjfso far, I have the name in alphabet order, but I also need to order/group X001 & Y012 together.I tried substring, but it didn't work because it's inconsistent. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-03-12 : 16:44:57
|
| will there be - always as a separator?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
ZkInPhamouS
Starting Member
5 Posts |
Posted - 2012-03-13 : 07:52:05
|
quote: Originally posted by visakh16 will there be - always as a separator?
Yeah, but I figured it out, by using substring_index, I could potentially narrow it down to what what I need, which is the middle section, the "X001" or "Y012"Thanks all! |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2012-03-13 : 07:54:47
|
So you are using MySQL? No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
ZkInPhamouS
Starting Member
5 Posts |
Posted - 2012-03-13 : 08:02:33
|
quote: Originally posted by webfred So you are using MySQL? No, you're never too old to Yak'n'Roll if you're too young to die.
Now that you pointed out, I want to apologize, yeah, it's MySQL, I just recently started learning it.I realized that I'm on the wrong forum after you mentioned it and I did a search for MySQL forum.Again, I apologize for all the trouble. |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2012-03-13 : 08:12:22
|
No problem since you were able to solve your problem by yourself (in order to answer on visakh's questions which brought you on the right track).  No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|