ForceChallenges
ProblemsDailyNotesInterview
Sign in

Practice

All problemsSOQL practiceApex trigger challengesDaily challengeOpportunityTrigger.oldMapBefore UpdateBulkificationContactValidationGROUP BYSemi-JoinAccountBefore Insert

Interview questions

All questionsAdminAdministrationApexApex TriggerAsync ApexDevelopmentField ServiceField ServiceIntegrationLwc

By company

DeloitteSalesforceAccentureInfosysPwCCognizant

Learn

Study notes

ForceChallenges

AboutContact usPrivacy PolicyTerms of ServiceFor AI assistants (llms.txt)
© 2026 ForceChallenges · Salesforce SOQL & Apex trigger practice
Development questions21 of 102
DevelopmentMedium 1 min read

Write a SOQL query to find all LoginHistory records for a specific User in the last 24 hours where the login status failed.

Asked atPwCEYKPMG

Answer

Filter LoginHistory by user, time window and non-success status.

apex
Datetime since = Datetime.now().addHours(-24);
List<LoginHistory> failed = [
    SELECT UserId, LoginTime, Status, SourceIp, LoginType, Application
    FROM LoginHistory
    WHERE UserId = :userId AND LoginTime >= :since AND Status != 'Success'
    ORDER BY LoginTime DESC
];

Using a datetime bind variable is the reliable way to express "last 24 hours", since date literals work in whole days.

soqlscenariologin-historyaudit
Practice SOQL & Apex
PreviousWrite a SOQL query to fetch all OpportunityLineItem records along with the Product Name (Product2.Name), Pricebook Name (PricebookEntry.Pricebook2.Name), and Account Name (Opportunity.Account.Name).Next Write a SOQL query using DISTANCE and GEOLOCATION to find all Warehouse Accounts within 25 miles of a given latitude and longitude.

More Development questions

  • What is reactivity in LWC and when does a field trigger a re-render?
  • What are the best practices to improve LWC performance?
  • How do you unit test an LWC with Jest?
  • How do you use a third-party JavaScript library or static resource in LWC?
  • Why can renderedCallback run multiple times and how do you prevent repeated execution?