ahmed elbarbary

ahmed elbarbary

  • NA
  • 1.6k
  • 278.5k

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 :
  1. CREATE TABLE [dbo].[RequestsEmail](  
  2.     [EmialRequestID] [int] IDENTITY(1,1) NOT NULL,  
  3.     [RequestID] [intNULL,  
  4.     [EmailID] [nvarchar](250) NULL,  
  5.     [ReplyToID] [nvarchar](250) NULL,  
  6.     [EmailDate] [datetime] NULL,  
  7. ON [PRIMARY 
  8. INSERT [dbo].[RequestsEmail] ( [RequestID], [EmailID], [ReplyToID], [EmailDate])   
  9. VALUES ( 39502, N'[email protected]', N'[email protected]','2020-03-17 05:08:11.740')  
  10. INSERT [dbo].[RequestsEmail] ( [RequestID], [EmailID], [ReplyToID], [EmailDate])   
  11. VALUES ( 39504, N'[email protected]', N'[email protected]','2019-05-05 05:08:11.740')  
  12. INSERT [dbo].[RequestsEmail] ( [RequestID], [EmailID], [ReplyToID], [EmailDate])   
  13. VALUES ( 39504, N'[email protected]'NULL,'2020-03-17 05:10:11.740')  
  14. INSERT [dbo].[RequestsEmail] ( [RequestID], [EmailID], [ReplyToID], [EmailDate])   
  15. VALUES ( 39504, N'[email protected]'NULL,'2020-03-17 05:15:11.740')  
  16. INSERT [dbo].[RequestsEmail] ( [RequestID], [EmailID], [ReplyToID], [EmailDate])   
  17. 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
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 ?

Answers (2)