Search This Blog

Tuesday, September 28, 2010

Custom Order By in MS SQL Server

Custom Order By

In MS SQL we cannot achieve sorting by using Order By on Varchar data type. We can do sorting on Int data type. To resolve this problem I suggest following solution. E.g. There is table in which AcadLevel is column having datatype varchar.Stored values are ‘Diploma’,'Graduate’,'PostGraduate’,'M.Phill’,'Ph.D.’.I want to display Higher AcademicLevel first followed by remaining.

E.g.

Ph.D.

M.Phill

PostGraduate

Graduate

Diploma.

For that I have used custom Order By.

SELECT Tr_ID ,
FacultyCourse ,
AcadLevel ,
dbo.M_Tech_Academics.FacultyCourse_ID ,
Subject_Name ,
CourseType ,
CollegeName ,
PassingYear ,
Faculty_ID
FROM dbo.M_Tech_Academics
INNER JOIN dbo.M_FacultyCourse ON dbo.M_Tech_Academics.FacultyCourse_ID = dbo.M_FacultyCourse.FacultyCourse_ID
WHERE Tr_ID = @Tr_ID
ORDER BY
CASE AcadLevel
WHEN ‘Ph.D.’ THEN 1
WHEN ‘M.Phill’ THEN 2
WHEN ‘PostGraduate’ THEN 3
WHEN ‘Graduate’ THEN 4
WHEN ‘Diploma’ THEN 5
END

Tuesday, February 23, 2010

Three-tier architecture in .net

Three-tier architecture in .net

Tuesday, November 10, 2009

My Pune City



Pune:-



Pune (pronounced [puɳeː], Marathi: पुणे), formerly known as Punawadi or Punya-Nagari or Poona, is the eighth largest city in India, and the second largest in the state of Maharashtra, after Mumbai. Situated 560 metres above sea level on the Deccan plateau at the confluence of the Mula (Marathi: मुळा) and Mutha rivers (Marathi: मुठा) [3], Pune is the administrative capital of Pune district and the 7th Metro city of India.

Pune is known to have existed as a town since 937 AD.[4] Shivaji, the founder of the Maratha Empire, lived in Pune as a boy, and later oversaw significant growth and development of the town during his reign. In 1730, Pune became an important political centre as the seat of the Peshwa, the prime minister of the Chhatrapati of Satara. After the town was annexed to British India in 1817, it served as a cantonment town and as the "monsoon capital" of the Bombay Presidency until the independence of India.

Today, Pune is known for its educational facilities, having more than a hundred educational institutes and nine universities[5]. Pune has well-established Manufacturing, Glass, Sugar and Metal Forging industries since 1950-60s. Pune also has a growing industrial hinterland, with many information technology and automotive companies setting up factories in Pune district. Additionally, Pune city is well known for various cultural activities like Classical Music, Sports, Literature, Foreign language learning and Administrative, Economics, Social Science studies. These activities and job opportunities attract migrants and students from all over India, and also attract students from Middle-East, Iran, Eastern Europe, South-East Asia which makes for a city of many communities and cultures.

Reference :- www.wikipedia.com