How to make her fall in love with you
![]() |
Posted by chandru14 on July 28, 2008
![]() |
Posted in Relationships | Tagged: love, Relationships | Leave a Comment »
Posted by chandru14 on July 28, 2008
|
Site URL |
Content |
|
Movie news, reviews, gossips, galleries |
|
|
Movie news, reviews, gossips, galleries |
|
|
Movie news, reviews, gossips, galleries |
|
|
Movie news, reviews, gossips, galleries |
|
|
Movie news, reviews, gossips, galleries |
|
|
Movie downloads, mp3 songs |
|
|
Movie news, reviews, gossips, galleries, downloads |
|
|
Movie download, songs, trailers, galleries |
|
|
Movie news, reviews, gossips, galleries |
|
|
Movie news, reviews, gossips, galleries |
|
|
Movie news, reviews, gossips, galleries, Interviews |
|
|
Movie news, reviews, gossips, galleries |
|
|
Movie news, reviews, gossips, galleries |
|
|
Movie downloads, galleries, reviews |
|
|
Movie news, reviews, gossips, galleries |
|
|
Movie news, reviews, gossips, galleries |
|
|
Movie downloads |
|
|
Movie news, reviews, gossips, galleries |
|
|
Movie download, mp3 songs |
|
|
Movie galleries |
Posted in Top movie sites | Tagged: galleries, gossips, Movie downloads, mp3 songs, reviews | 2 Comments »
Posted by chandru14 on July 27, 2008
Hello friends J,
SQL Server 2005 has introduced some new ranking functions which make our job more easy when ever we want to assign ranks to employees / stundets based on different criteria.
Some of us might argue over that we can achieve the same ranking using ROW_NUMBER() function but the problem here is it always provides sequential values like 1,2,3,4 etc even though two are more records have the same ranking criteria. To avoid such issues, we can use RANK() or DENSE_RANK() based on the requirement.
I hope you find this article useful for you J. Here is the example.
Click here to download the script
Example:-
CREATE TABLE Dept( Dept_id INT PRIMARY KEY, DeptName VARCHAR(100), Loc VARCHAR(100))
GO
INSERT INTO Dept VALUES(101,‘Admin’,‘Chennai’)
INSERT INTO Dept VALUES(102,‘Sales’,‘Hyderabad’)
INSERT INTO Dept VALUES(103,‘Operations’,‘Delhi’)
INSERT INTO Dept VALUES(104,‘IT’,‘Banglore’)
GO
CREATE TABLE Employee(Emp_id INT PRIMARY KEY, EmpName VARCHAR(100),DOJ DATETIME, Salary MONEY, Dept_id INT REFERENCES Dept(Dept_id))
GO
INSERT INTO Employee VALUES(1001,‘Chandra’,’15-Dec-2004′,10000,104)
INSERT INTO Employee VALUES(1002,‘VVS’,’01-Jan-2005′,30000,104)
INSERT INTO Employee VALUES(1003,‘Pagalavan’,’15-Oct-2005′,40000,104)
INSERT INTO Employee VALUES(1004,‘ASN’,’10-Feb-2006′,20000,104)
INSERT INTO Employee VALUES(1005,‘Sathish’,’19-Dec-2005′,10000,104)
INSERT INTO Employee VALUES(1006,‘Sri’,’06-Sep-2007′,50000,104)
INSERT INTO Employee VALUES(1007,‘Sangeetha’,’10-Nov-2007′,15000,104)
INSERT INTO Employee VALUES(1008,‘Manick’,’25-Jan-2006′,20000,104)
INSERT INTO Employee VALUES(1009,‘Kanchana’,’15-Feb-2005′,19000,104)
INSERT INTO Employee VALUES(1010,‘Arun’,’15-Mar-2005′,12000,103)
INSERT INTO Employee VALUES(1011,‘Zahed’,’05-Apr-2004′,11000,103)
INSERT INTO Employee VALUES(1012,‘Rajesh’,’14-May-2005′,60000,103)
INSERT INTO Employee VALUES(1013,‘Ila’,’15-Jun-2006′,80000,102)
INSERT INTO Employee VALUES(1014,‘Remya’,’15-Jul-2006′,40000,102)
INSERT INTO Employee VALUES(1015,‘Tito’,’15-Aug-2008′,70000,102)
INSERT INTO Employee VALUES(1016,‘RP’,’11-Sep-2007′,30000,102)
INSERT INTO Employee VALUES(1017,‘Khiroj’,’18-Oct-2008′,40000,102)
INSERT INTO Employee VALUES(1018,‘Gopi’,’20-Nov-2005′,60000,101)
INSERT INTO Employee VALUES(1019,‘Venkat’,’12-Dec-2007′,10000,101)
INSERT INTO Employee VALUES(1020,‘JJR’,’12-Jan-2006′,15000,101)
INSERT INTO Employee VALUES(1021,‘Shivan’,’15-Feb-2008′,25000,101)
GO
/* Either of the following queries provide the rank for each employee based on salary.*/
SELECT Top 5 *, RANK() OVER (ORDER BY Salary DESC) AS Rank FROM Employee
Output :-
|
Emp_id |
EmpName |
DOJ |
Salary |
Dept_id |
Rank |
|
1013 |
Ila |
6/15/2006 |
80000 |
102 |
1 |
|
1015 |
Tito |
8/15/2008 |
70000 |
102 |
2 |
|
1012 |
Rajesh |
5/14/2005 |
60000 |
103 |
3 |
|
1018 |
Gopi |
11/20/2005 |
60000 |
101 |
3 |
|
1006 |
Sri |
9/6/2007 |
50000 |
104 |
5 |
SELECT Top 5 *, DENSE_RANK() OVER (ORDER BY Salary DESC) AS Rank FROM Employee
Output :-
|
Emp_id |
EmpName |
DOJ |
Salary |
Dept_id |
Rank |
|
1013 |
Ila |
6/15/2006 |
80000 |
102 |
1 |
|
1015 |
Tito |
8/15/2008 |
70000 |
102 |
2 |
|
1012 |
Rajesh |
5/14/2005 |
60000 |
103 |
3 |
|
1018 |
Gopi |
11/20/2005 |
60000 |
101 |
3 |
|
1006 |
Sri |
9/6/2007 |
50000 |
104 |
4 |
Using Partition BY clause:-
/* Either of the following queries provide the rank for each employee based on salary grouped by department*/
SELECT *, RANK() OVER (PARTITION BY Dept_id ORDER BY Salary DESC) AS Rank
FROM Employee
GO
SELECT *, DENSE_RANK() OVER (PARTITION BY Dept_id ORDER BY Salary DESC) AS Rank
FROM Employee
Note:-
There is a slight difference between RANK() and DENSE_RANK().
In case of RANK() function If two or more rows tie for a rank, each tied rows receives the same rank.
For example, if the two top employees have the same salary, they are both ranked one. The employee with next highest salary is ranked number three
In case of DENSE_RANK() If two or more rows tie for a rank , each tied rows receives the same rank.
For example, if the two top employees have the same salary, they are both ranked one. The employee with the next highest salary is ranked number two.
Posted in SQL Server | Tagged: DENSE_RANK(), RANK(), SQL Server | Leave a Comment »
Posted by chandru14 on July 27, 2008
|
Site URL |
Content |
|
Movie news, galleries, reviews |
|
|
Movie news, galleries, reviews |
|
|
Movie news, galleries, reviews |
|
|
Movie news, galleries, reviews, mp3 songs |
|
|
Movies, mp3 songs, reviews, galleries, news |
|
|
Movies, mp3 songs, news, galleries |
|
|
Movie news, galleries, reviews |
|
|
Movie news, galleries, reviews |
|
|
Movie database |
|
|
Movie news, gossips, galleries |
|
|
Movie news, gossips, galleries |
|
|
Movie clips, mp3 songs |
|
|
Movie news, reviews galleries |
|
|
Mp3 songs, movie clips, |
|
|
Movie news, galleries, reviews |
|
|
Movie news, galleries, reviews |
|
|
Movie news, galleries, downloads |
|
|
Movie downloads |
|
|
Video downloads |
|
|
Movie news, galleries, reviews |
Posted in Top movie sites | Tagged: galleries, movie news, movie sites, mp3 songs, reviews, video downloads | 2 Comments »
Posted by chandru14 on July 25, 2008
|
Telugu |
Gossips, movie reviews, galleries |
|
|
|
Movie reviews, gallaries |
|
|
Movie reviews, galleries,gossips,MP3 download, video songs downloads |
||
|
Movie news, galleries, reviews |
||
|
Movie news, galleries |
||
|
Movie news, galleries |
||
|
New songs, mp3 downloads, movie news |
||
|
New songs, mp3 downloads, movie news |
||
|
Movie news, reviews, galleries |
||
|
Gossips, movie reviews, galleries |
||
|
Gossips, movie reviews, galleries |
||
|
Gossips, movie reviews, galleries |
||
|
Gossips, movie reviews, galleries |
||
|
Gossips, movie reviews, galleries |
||
|
Gossips, movie reviews, galleries |
||
|
Gossips, movie reviews, galleries |
||
|
Gossips, movie reviews, galleries |
||
|
Gossips, movie reviews, galleries |
||
|
Gossips, movie reviews, galleries |
Posted in Top movie sites | Tagged: galleries, movie news, movie sites, mp3 songs, reviews, video downloads | 2 Comments »
Posted by chandru14 on July 24, 2008
Hello Friends J,
Generally Paging / Pagination concept is used in ASP.Net to display the records in multiple pages instead of displaying all at once and this increases the response time of the web page also.
So far this paging is being handled by ADO.Net( I don’t know how it works internally L) and we used to implement the logic with a complex logic in SQL server earlier
But in SQL Server 2005, very easyly we can apply the pagination / select specific range of records from a result seet with the help of WITH common table expression and ROW_NUMBERR() which is a ranking function
I hope you find this article useful J
Click here to download the script
Example:-
CREATE TABLE Dept( Dept_id INT PRIMARY KEY, DeptName VARCHAR(100), Loc VARCHAR(100))
GO
INSERT INTO Dept VALUES(101,‘Admin’,‘Chennai’)
INSERT INTO Dept VALUES(102,‘Sales’,‘Hyderabad’)
INSERT INTO Dept VALUES(103,‘Operations’,‘Delhi’)
INSERT INTO Dept VALUES(104,‘IT’,‘Banglore’)
GO
CREATE TABLE Employee(Emp_id INT PRIMARY KEY, EmpName VARCHAR(100),DOJ DATETIME, Salary MONEY, Dept_id INT REFERENCES Dept(Dept_id))
GO
INSERT INTO Employee VALUES(1001,‘Chandra’,’15-Dec-2004′,10000,104)
INSERT INTO Employee VALUES(1002,‘VVS’,’01-Jan-2005′,30000,104)
INSERT INTO Employee VALUES(1003,‘Pagalavan’,’15-Oct-2005′,40000,104)
INSERT INTO Employee VALUES(1004,‘ASN’,’10-Feb-2006′,20000,104)
INSERT INTO Employee VALUES(1005,‘Sathish’,’19-Dec-2005′,10000,104)
INSERT INTO Employee VALUES(1006,‘Sri’,’06-Sep-2007′,50000,104)
INSERT INTO Employee VALUES(1007,‘Sangeetha’,’10-Nov-2007′,15000,104)
INSERT INTO Employee VALUES(1008,‘Manick’,’25-Jan-2006′,20000,104)
INSERT INTO Employee VALUES(1009,‘Kanchana’,’15-Feb-2005′,19000,104)
INSERT INTO Employee VALUES(1010,‘Arun’,’15-Mar-2005′,12000,103)
INSERT INTO Employee VALUES(1011,‘Zahed’,’05-Apr-2004′,11000,103)
INSERT INTO Employee VALUES(1012,‘Rajesh’,’14-May-2005′,60000,103)
INSERT INTO Employee VALUES(1013,‘Ila’,’15-Jun-2006′,80000,102)
INSERT INTO Employee VALUES(1014,‘Remya’,’15-Jul-2006′,40000,102)
INSERT INTO Employee VALUES(1015,‘Tito’,’15-Aug-2008′,70000,102)
INSERT INTO Employee VALUES(1016,‘RP’,’11-Sep-2007′,30000,102)
INSERT INTO Employee VALUES(1017,‘Khiroj’,’18-Oct-2008′,40000,102)
INSERT INTO Employee VALUES(1018,‘Gopi’,’20-Nov-2005′,60000,101)
INSERT INTO Employee VALUES(1019,‘Venkat’,’12-Dec-2007′,10000,101)
INSERT INTO Employee VALUES(1020,‘JJR’,’12-Jan-2006′,15000,101)
INSERT INTO Employee VALUES(1021,‘Shivan’,’15-Feb-2008′,25000,101)
GO
/*Displays Employee records ranging from 11 to 20*/
WITH EmpDetails AS
(
SELECT *, ROW_NUMBER() OVER (ORDER BY Emp_id DESC) AS RowNum FROM Employee
)
SELECT * FROM EmpDetails WHERE RowNum BETWEEN 11 AND 20
/*Displays Top two employees who are getting highest salary in each department*/
WITH EmpDetails AS
(
SELECT *, ROW_NUMBER() OVER (PARTITION BY Dept_id ORDER BY Salary DESC) AS RowNum FROM Employee
)
SELECT * FROM EmpDetails WHERE RowNum BETWEEN 1 AND 2
Posted in SQL Server | Tagged: Pagination, ROW_NUMBER(), SQL Server, WITH | 2 Comments »
Posted by chandru14 on July 21, 2008
Hello friends,
You might have come across some situations where you need to display the records from a table in a random order. Especially this is a common task for applications which conducts online examinations.
We can handle this situation very easily using a SQL function NewID() which generates a unique value of type uniqueidentifier with every call
Example:-
CREATE TABLE Question(Question_id INT, QuestionText VARCHAR(2000))
GO
INSERT INTO Question VALUES(101,‘Tallest building?’)
INSERT INTO Question VALUES(102,‘Longest bridge?’)
INSERT INTO Question VALUES(103,‘Total countries in world?’)
INSERT INTO Question VALUES(104,‘fastest animal?’)
INSERT INTO Question VALUES(105,‘Total no of states in india?’)
INSERT INTO Question VALUES(106,‘abc?’)
INSERT INTO Question VALUES(107,‘xyz?’)
INSERT INTO Question VALUES(108,’123?’)
INSERT INTO Question VALUES(109,‘mtr?’)
GO
SELECT
Question_id
,QuestionText
,NEWID() AS RandomKey
FROM Question
ORDER BY RandomKey
Click here to download the script
Posted in SQL Server | Tagged: NewId(), SQL Server | Leave a Comment »