আমার নিম্নলিখিত টেবিল রয়েছে:
==========================================================
| Name_Level_Class_Section | Phone Num |
==========================================================
| Jacky_1_B2_23 | 1122554455 |
| Johnhy_1_B2_24 | 1122554455 |
| Peter_2_A5_3 | 1122554455 |
==========================================================
আমি নিম্নলিখিত হিসাবে আমার এসকিউএল বিবৃতি সরল করার চিন্তা করছি:
select
*,
substring(Name_Level_Class_Section,
CHARINDEX('_',Name_Level_Class_Section,
(CHARINDEX('_', Name_Level_Class_Section) + 1)) + 1,
CHARINDEX('_',Name_Level_Class_Section,
(CHARINDEX('_',Name_Level_Class_Section,
(CHARINDEX('_',Name_Level_Class_Section)+1))+1))-
CHARINDEX('_',Name_Level_Class_Section,
(CHARINDEX('_',Name_Level_Class_Section)+1))) as CLA
from
Bookings
order by
CLA asc, Name_Level_Class_Section asc
যাতে আমি যখন এসকিউএল সম্পাদন করি তখন এটি আমাকে নিম্নলিখিত ফলাফল দেয়:
==========================================================
| Name_Level_Class_Section | Phone Num | CLA |
==========================================================
| Jacky_1_B2_23 | 1122554455 | B2 |
| Johnhy_1_B2_24 | 1122554455 | B2 |
| Peter_2_A5_3 | 1122554455 | A5 |
==========================================================
আমার এসকিউএল সরল করার কোনও উপায় আছে?