Search - Articles
DevASP.NET for ASP.NET, VB.NET, XML and C# (C-Sharp) Developers Tuesday, March 03, 2009
Dev Articles
Search Directory
ASP.NET
VB.Net
C-Sharp
SQL Server
 

Comparing Date Colmumns using PLSQL in Sql Server 2005

Author: Zunnair

In the article i will show you the better for doing the Comparison.

In this article i will tell you the way in which we can compare dates Custom techinque

we can compare dates by Following ways

1- By using Curson

2- By using Cross Join

3- By using different kinds of inner queeris

I will tell you the way which is fall in thrid category So

Just follow the Steps

1- Make a PersonRecord  table 

2- insert some Records of different date

3- and finally Copy the querry and run it

CREATE TABLE PersonRecord ( PersonID int, Version int,DEDate datetime)
go
INSERT INTO PersonRecord VALUES(2,0,'02/10/2008')
INSERT INTO PersonRecord VALUES(2,1,'02/11/2008')
INSERT INTO PersonRecord VALUES(2,2,'02/18/2008')
INSERT INTO PersonRecord VALUES(3,0,'03/25/2008')
INSERT INTO PersonRecord VALUES(3,1,'03/23/2008')
INSERT INTO PersonRecord VALUES(3,2,'03/26/2008')
INSERT INTO PersonRecord VALUES(3,3,'03/30/2008')
INSERT INTO PersonRecord VALUES(4,0,'08/19/2008')
INSERT INTO PersonRecord VALUES(4,1,'08/20/2008')

 

go
SELECT *,(SELECT CASE WHEN (SUM(CASE WHEN B.DEDate=1
   THEN 1 ELSE 0 END AS IsnotProper from PersonRecord B CROSS JOIN  PersonRecord C
   WHERE B.PersonID=A.PersonID AND C.PersonID=A.PersonID AND B.VERSION<>C.VERSION
   AND B.VERSIONfrom PersonRecord A

we can do it by many other ways but we should pick the best one with respect to Cost.

I hope this article will left the Good understanding to you

   
Add Article Comment:
Name :
Email Address :
   
Comments :
 
   
<< How we can validate Numeric Box using JavaScript in VS 2005

Disclaimer - Privacy
© 2002-2017 DevASP.net