You must have to concern data sorting when you work with wide range of data source. Well nothing to say more about shorting which is very important. Okay let’s consider the following scenario:
You have a table with few columns & you will sort the table based on a specific column that contains numeric value with
type value. A sample table is given below:
1 368 Mirpur
2 243 Gulshan
3 101 DOHS
So now, you have to sort the table base on c2, how can you do that? It’s very simple, to achieve this we will use
function. The following query will resolve the issue.
DECLARE @tempTable TABLE (id INT, String_WithN_umericValue VARCHAR(100))
INSERT INTO @tempTable VALUES (1,’7th’)
INSERT INTO @tempTable VALUES(2,’4th’)
INSERT INTO @tempTable VALUES(3,’9th’)
INSERT INTO @tempTable VALUES(4,’10th’)
INSERT INTO @tempTable VALUES(5,’2nd’)
INSERT INTO @tempTable VALUES(6,’5th’)
INSERT INTO @tempTable VALUES(7,’8th’)
INSERT INTO @tempTable VALUES(8,’1st’)
INSERT INTO @tempTable VALUES(9,’3rd’)
INSERT INTO @tempTable VALUES(10,’6th’)
SELECT * FROM @tempTable ORDER BY CAST(LEFT(String_WithN_umericValue,PATINDEX(‘%[^0-9]%’,String_WithN_umericValue)-1) AS INT)
More information about
function can be found at this link
A highly experienced leader with successful track record of software development, product innovations, brand management and corporate communication etc. Some successful product innovations have also achieved and awards “Most Valuable Professional” (MVP) at 2010 and 2011 by codeproject.com and also selected as a mentor of codeproject.com. Published over 100 technical articles in various software development resource sites (i.e., codeprojetc.com, Microsoft MSDN, and IEEE & IBM (In progress)) and various IT Forums, Blogs etc.
Over ten years of professional experiences in ICT field having extensive experience in formulating corporate vision and long term strategy. Leading development related functions including design, development, services, data management and analytics, customer experience management, content services, digital analytics and optimization.
An individual with results-driven approach and relentless in pursuit of excellence from a business and organizational standpoint. Believes in transparency, commitment and teamwork.
Expertise: Software/Solution Architect, SaaS platform base application, Large scale win32/web based business software solutions, enterprise applications, integration, etc.
Technologies/Tools: Microsoft.Net version 05/08/10/12, Microsoft SQL Server version 7/2K/05/08/12 , Oracle version 10/11, MySql version 5.1, 5.5, PS2, Visual C#, R, VB.NET, ASP.NET, PHP, API, MVC, WebAPI , Add-In Visual Basic etc.,. I have also more than two years’ of strong experience in mobile-VAS (platform development).
Points of Interest: Technology and research & development especially focused on business functionalities and social business areas as well, few stuff including:
1.R&D on new techniques as required to increase business revenue.
2.Urban and rural sectors to improve people’s lifestyle, better medical facilities, education, social business etc., using innovative technical solutions.
3.Research and innovative product development.