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
ahmed elbarbary
597
1.6k
282.4k
How to select data from RequestesEmail table based on two co
Mar 16 2020 10:32 PM
How to select data from RequestesEmail table based on two condition on same time ?
I work on SQL server 2012
I have table request emails register email requested and replies
structure table as following :
CREATE
TABLE
[dbo].[RequestsEmail](
[EmialRequestID] [
int
] IDENTITY(1,1)
NOT
NULL
,
[RequestID] [
int
]
NULL
,
[EmailID] [nvarchar](250)
NULL
,
[ReplyToID] [nvarchar](250)
NULL
,
[EmailDate] [datetime]
NULL
,
)
ON
[
PRIMARY
]
INSERT
[dbo].[RequestsEmail] ( [RequestID], [EmailID], [ReplyToID], [EmailDate])
VALUES
( 39502, N
'
[email protected]
'
, N
'
[email protected]
'
,
'2020-03-17 05:08:11.740'
)
INSERT
[dbo].[RequestsEmail] ( [RequestID], [EmailID], [ReplyToID], [EmailDate])
VALUES
( 39504, N
'
[email protected]
'
, N
'
[email protected]
'
,
'2019-05-05 05:08:11.740'
)
INSERT
[dbo].[RequestsEmail] ( [RequestID], [EmailID], [ReplyToID], [EmailDate])
VALUES
( 39504, N
'
[email protected]
'
,
NULL
,
'2020-03-17 05:10:11.740'
)
INSERT
[dbo].[RequestsEmail] ( [RequestID], [EmailID], [ReplyToID], [EmailDate])
VALUES
( 39504, N
'
[email protected]
'
,
NULL
,
'2020-03-17 05:15:11.740'
)
INSERT
[dbo].[RequestsEmail] ( [RequestID], [EmailID], [ReplyToID], [EmailDate])
VALUES
( 39504, N
'
[email protected]
'
, N
'
[email protected]
'
,
'2018-02-09 05:15:11.740'
)
all data on table as below
EmialRequestID RequestID EmailID ReplyToID EmailDate
1 39502
[email protected]
[email protected]
2020-03-17 05:08:11.740
2 39504
[email protected]
[email protected]
2019-05-05 05:08:11.740
3 39504
[email protected]
NULL 2020-03-17 05:10:11.740
4 39504
[email protected]
NULL 2020-03-17 05:15:11.740
5 39504
[email protected]
[email protected]
2018-02-09 05:15:11.740
desire result is
EmialRequestID RequestID EmailID ReplyToID EmailDate
1 39502
[email protected]
[email protected]
17/03/2020
3 39504
[email protected]
NULL 17/03/2020
4 39504
[email protected]
NULL 17/03/2020
Actually i need to make select statement display or show all data on table RequestEmail above structure
where
first condtition
ReplyToID is null and EmailDate equal datetoday
and also second condition
select EmailID where equal ReplyToID and EmailDate is dateToday
two condition on same time must show .
so how to do that please ?
Reply
Answers (
2
)
How to rewrite query below with best practise way ?
Having problem connecting to database