Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
8
Reply
If condition in Where Clause in SQL Query(Please help)
Riddhi Valecha
Nov 26 2013 1:43 AM
1.8k
Reply
Hi all...
I have a table like below in the database.
ID
Username
Date1
Date2
101
abc
2012-11-01
NULL
102
def
2012-12-03
2013-01-05
103
ghi
2011-02-04
2012-03-04
104
jkl
2012-02-03
2013-01-01
105
mno
NULL
NULL
106
pqr
NULL
2013-04-01
Now, I want to use the "IF-Condition" in my sql query such that -
select * from table where Date1<Date2 and Date1 is not null and Date2 is not null, and Total Days between Date1 and Date2.
The result i want is -
ID
Username
Date1
Date2
Total Datys
101
abc
2012-11-01
NULL
Null
102
def
2012-12-03
2013-01-05
10
103
ghi
2011-02-04
2012-03-04
10
104
jkl
2012-02-03
2013-01-01
0 (Date1> Date2)
105
mno
NULL
NULL
Null
106
pqr
NULL
2013-04-01
Null
How do I get this?? Please help...
Thanks a ton in advance....
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
8
)
Next Recommended Forum
how to insert function value in coloumn
connetion string classic asp oracle database