TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Riddhi Valecha
438
3.3k
415.4k
If condition in Where Clause in SQL Query(Please help)
Nov 26 2013 1:43 AM
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....
Reply
Answers (
8
)
Help in listbox binding parent and child. move to next listb
Sql Query?