Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Brain Freeze
Message
From
30/10/2015 11:22:29
 
 
To
30/10/2015 09:56:53
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Title:
Environment versions
SQL Server:
SQL Server 2014
Application:
Web
Miscellaneous
Thread ID:
01626701
Message ID:
01626707
Views:
46
>>The smart safe transaction table has two possible eventcode values DECL and VER
>>
>>a VER transaction can relate to one or DECL transactions.
>>
>>The verifyid column in a DECL transaction points to the VER transaction for that row, if any.
>>
>>I was to select ALL DECL rows where the verifyid column is 0 or if it's not zero the postingdate in the related VER transaction is earlier than a given date
>>
>>I get this far and go blank
>>
>>
>>select * from view_expandedsmartsafetrans where eventcode = 'DECL' and verifyid = 0 
>>
>
>
>select *;
>      from view_expandedsmartsafetrans VEXP;
>LEFT JOIN VER ON VER.verifyid = VEXP.verifyid AND VEXP.transaction < SomeDate
>where VEXP.eventcode = 'DECL';
> and VEXP.verifyid = 0 OR VER.verifyid IS NOT NULL
>
>NOT TESTED!
DECLARE @selectdate DATETIME
SELECT @selectdate = '2015-10-31'
select * from view_expandedsmartsafetrans where eventcode = 'DECL' and verifyid = 0 
OR (verifyid <> 0 AND  verifyid IN  (SELECT idcol FROM smartsafetrans WHERE eventcode =  'VER' AND postingdate < @selectdate ))
This worked.
Thanks to all for your advice
Yes, a second coffee is amazing.
Boris, we needed to define VER
Anyone who does not go overboard- deserves to.
Malcolm Forbes, Sr.
Previous
Reply
Map
View

Click here to load this message in the networking platform