Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 5 of 5 total
Thread Need some SQL Wizardry..
Tue, Sep 11 2018 10:52 PMPermanent Link

Ian Branch

Avatar




Attachments: Screenshot_1.jpg
Wed, Sep 12 2018 2:47 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Ian


OK

1. a query to get the appropriate row

SELECT * FROM table WHERE DTG >= CURRENT_TIMESTAMP RANGE 1 TO 1

or as a parameterised query

SELECT * FROM table WHERE DTG >= :Wanted RANGE 1 TO 1

2. some Delphi code

query1.close;
{only if parameterised query}
if not query1.prepared then query1.Prepare;
query1.ParamByName('Wanted').AsTimestamp := Now; // or whenever you want

query1.ExecSQL;
LogEvent := query1.fieldbyname('LogEvent').AsString;

LogUser := Copy(LogEvent,6,MaxInt);
LogUser := Copy(LogUser,1,Pos('has',LogUser)-1);


should do it

Roy Lambert
Wed, Sep 12 2018 7:38 PMPermanent Link

Ian Branch

Avatar




Attachments: Screenshot_2.jpg
Thu, Sep 13 2018 2:31 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Ian


If you want pure SQL then you need a script. Export the table data in xml format and email it to me and I'll sort something out.

Before I start I need a "specification" or at least a few points clarifying:

at any point in time - means to the nearest minute - yes/no

Who was logged in at that time - in the example you've shown that translated to who logged in at that time not who logged in earlier and never logged out again. If you want genuine who was logged in then the entire table needs to be scanned for login/logout pairs. - what is the real requirement?

Roy Lambert
Thu, Sep 13 2018 2:47 AMPermanent Link

Ian Branch

Avatar

Hi Roy,
   Please see email just sent.
Regards,
Ian
Image