Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8017021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:42:48+00:00 2026-06-04T20:42:48+00:00

I have a table for logging a Facebook application user actions. I want to

  • 0

I have a table for logging a Facebook application user actions. I want to get the latest row that is not older then 9 minutes for a specific action ID. The table has a lot of columns of other statistical information, so I will show only 2 of the rows that represent the problem:

timestamp                  facebookID   producerID      eventID   actionID   numOfTickets
2012-05-28 13:16:38     100003286974944    9             1741        cpf      2
2012-05-28 13:16:13     100003286974944    9             1741        cpf      4

What I want to do is getting the latest row where actionID = 'cpf'.

What I’ve tried is:

SELECT CONCAT_WS(' ', y.firstName, y.lastName) as fullName, x.facebookID, x.numOfTickets, MAX(x.timestamp) 
FROM E4S_ANALYTICS.e4s_analytic_data x INNER JOIN E4S_FB.e4s_user_details y ON x.facebookID = y.facebookID 
WHERE (x.actionID = 'CPF' AND x.numOfTickets > 0 AND x.producerID = 9 AND TIMEDIFF(NOW() , x.timestamp) < '00:09:00' 
AND x.facebookID IN (SELECT facebookID FROM  E4S_FB.e4s_session_data WHERE 
                     TIMEDIFF(NOW() , sessionStart) < '00:09:00' ))

The result of the query is:

facebookID      numOfTickets    MAX(x.timestamp)
100003286974944  4              2012-05-28 13:16:38

The timestamp returned is correct but the numOfTickets is 4 instead of 2.

For note, the inner query:

SELECT facebookID FROM  E4S_FB.e4s_session_data 
WHERE TIMEDIFF(NOW() , sessionStart) < '00:09:00' ))

Is used to see who is still logged in to the application.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T20:42:49+00:00Added an answer on June 4, 2026 at 8:42 pm
    SELECT CONCAT_WS(' ', y.firstName, y.lastName) AS fullName,
           x.facebookID,
           x.numOfTickets,
           x.timestamp
    FROM   (
             SELECT *
             FROM   E4S_ANALYTICS.e4s_analytic_data
             WHERE  actionID = 'cpf'
                AND numOfTickets > 0
                AND producerID = 9
                AND TIMEDIFF(NOW() , timestamp) < '00:09:00' 
                AND (facebookID, timestamp) IN (
                      SELECT   facebookID, MAX(timestamp)
                      FROM     E4S_ANALYTICS.e4s_analytic_data
                      WHERE    actionID = 'cpf'
                           AND numOfTickets > 0
                           AND producerID = 9
                           AND TIMEDIFF(NOW() , timestamp) < '00:09:00' 
                           AND facebookID IN (
                                 SELECT facebookID
                                 FROM   E4S_FB.e4s_session_data
                                 WHERE  TIMEDIFF(NOW() , sessionStart) < '00:09:00'
                               )
                      GROUP BY facebookID
                    )
           ) AS x
      INNER JOIN E4S_FB.e4s_user_details AS y USING (facebookID)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application that records activity in a table (Oracle 10g). The logging
I have a logging table that stores the user id, date/time, table name, record
I have a table logging application activity. Each row contains a DateTime (Time) and
I use SQL Server 2005. I have a simple logging table that my web
For a user logging table I have in a SQL database, I track the
We have a PHP/MySQL application and I want to setup a logging mechanism to
I have a logging table on the master server that is inserted into very
I have a table containing events which happen in my application like people logging
We have a Silverlight application that uses WCF Data Services. We want to add
I have a small report/logging application written in C#.NET 4.0 and WPF that I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.