Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
masond
Constraint Violating Yak Guru
447 Posts |
Posted - 2014-03-03 : 07:48:00
|
Hey all i need some help Aim – Only find Fdmsaccountno where Account_Status <> 16 on period_DT “2012-12-01 00:00:00” however Account_Status = 16 on “2012-11-01 00:00:00”I use the following conversion on period_Dt CONVERT(VARCHAR(24),period_DT,120) Looking forward to your help RegardsD |
|
VeeranjaneyuluAnnapureddy
Posting Yak Master
169 Posts |
Posted - 2014-03-03 : 07:55:46
|
can u plz provide the sample dataVeera |
 |
|
masond
Constraint Violating Yak Guru
447 Posts |
Posted - 2014-03-03 : 08:02:01
|
Hi VeeraThis would need to be includedFDMSAccountNo Account_Status Period_DT295268 16 2012-11-01 00:00:00295268 13 2012-12-01 00:00:00This would need to be excluded.FDMSAccountNo Account_Status Period_DT295268 16 2012-11-01 00:00:00295268 16 2012-12-01 00:00:00FDMSAccountNo Account_Status Period_DT295268 13 2012-11-01 00:00:00295268 16 2012-12-01 00:00:00 |
 |
|
masond
Constraint Violating Yak Guru
447 Posts |
Posted - 2014-03-03 : 10:30:41
|
Any one got any solutions ? |
 |
|
xhostx
Constraint Violating Yak Guru
277 Posts |
Posted - 2014-03-03 : 12:14:55
|
please provide you SQL. and it looks like the results you trying to include/exclude match. So, be little explicite please.--------------------------Joins are what RDBMS's do for a living |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2014-03-03 : 13:06:48
|
Not fully clear but from your sample data looks like thisSELECTFROM table tWHERE NOT EXISTS (SELECT 1FROM tableWHERE FDMSAccountNo = t.FDMSAccountNo AND Period_DT ='20121201'AND Account_Status = 16)AND EXISTS (SELECT 1FROM tableWHERE FDMSAccountNo = t.FDMSAccountNo AND Period_DT ='20121101'AND Account_Status = 16) ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
 |
|
MIK_2008
Master Smack Fu Yak Hacker
1054 Posts |
Posted - 2014-03-03 : 14:01:29
|
Or may be this? SELECT Fdmsaccountno FROM TableAWHERE (Account_Status <> 16 AND period_DT = '2012-12-01 00:00:00')OR (Account_Status = 16 AND period_DT = '2012-11-01 00:00:00')However, the confusing part is the following record which you said to be included as well as excluded in your narrative... 295268 16 2012-11-01 00:00:00CheersMIK |
 |
|
|
|
|