Posts

Showing posts with the label Query

Distinct count in MS SQL

The below code will retrieve distinct count from a table in SQL select ename, count(ename) from emp Group by ename having (count(ename)>1)

Converting Text number into number in Order By in SQL

Select * from emp order by code [ here 'code' is a text field], result in unordered result due to the data type, in MS SQL and My SQL too. To override this issue we can simply cast the field code using the cast  operator. select * from emp order by cast (code as int) Asc