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 brand management, product innovations and corporate communication. 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
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, 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.
Specialties: Developing client-server with multi-tier application, database design, web based business software solutions, enterprise applications, google analytics, etc., for Windows / Mac using Microsoft SQL Server, Oracle, MySql, PS, 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).