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 1051245
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:54:04+00:00 2026-05-16T16:54:04+00:00

Current query gives me all event_type = 1, for every day after 8/1/2010 I

  • 0

Current query gives me all event_type = 1, for every day after 8/1/2010
I only want the first occurrence per trustee of event_type 1 for each day after 8/1/2010.

SELECT trustee, event_time, event_type
FROM mytable
WHERE event_type = 1
AND event_time > '8/1/2010'
Order BY event_time;
  • 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-05-16T16:54:04+00:00Added an answer on May 16, 2026 at 4:54 pm

    Something like this?

    SELECT
        trustee,
        CAST( event_time AS DATE ) AS event_date,
        MIN( event_time ) AS first_event,
        event_type
    FROM mytable
    WHERE
        event_type = 1
    AND event_time > '2010-01-08'
    GROUP BY
        trustee, CAST( event_time AS DATE )
    ORDER BY
        event_time
    

    The trick is to group by just the date part of the event_time, ignoring the time-of-day, as well as the trustee.
    Within each group, find the first time.

    This won’t return a record for a date if there is no data for that trustee on that date.

    Update

    If you’re using an earlier (pre-2008?) version of SQL Server that doesn’t have a built-in DATE type then you can achieve similar using CONVERT and a suitable style argument that uses only the date part of the datetime (I can’t test this at present, apologies):

    SELECT
        trustee,
        CONVERT( VARCHAR, event_time, 110 ) AS event_date,
        MIN( event_time ) AS first_event,
        event_type
    FROM mytable
    WHERE
        event_type = 1
    AND event_time > '2010-01-08'
    GROUP BY
        trustee, CONVERT( VARCHAR, event_time, 110 ) 
    ORDER BY
        event_time
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First, I have to enumerate all the AD groups of the current user. Getting
My current query reads: SELECT entry_id, user_id, cat_id, AVG( rating ) as avg_rate FROM
Here is the updated question: the current query is doing something like: $sql1 =
I need to combine my main query with a subquery: Current query (which works):
the current SQL query works fine locally on MAMP 1.8.4 running MySQL 5.1.37. SELECT
My current LINQ query and example XML are below. What I'd like to do
Is there a way to query the current DATEFORMAT SQLServer 2005 is currently using
Is is possible to query the current browser from within an applet? I would
Beside query string root folder how do i get the current doc library list(ListName)
If I have a query like this: String Category = HttpContext.Current.Request.QueryString[Product].ToString(); IQueryable<ItemFile> pressReleases =

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.