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

  • SEARCH
  • Home
  • 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 399805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T16:52:56+00:00 2026-05-12T16:52:56+00:00

I totally can’t get my head around writing a correct query for my problem

  • 0

I totally can’t get my head around writing a correct query for my problem this morning so here’s hoping that someone out there can help me out.

I have a database table called Sessions which basically looks like this

Sessions:
  SessionID
  SessionStarted
  IPAddress
  ..other meta data..

I have a requirement where I am to show how many new Sessions (where new is defined as from a previously unseen IPAddress) arrive each day over a given period. Basically, each IPAddress should count only once in the results, namely for the day of the first session from the IPAddress. So I’m looking for a result like:

[Date]      [New]
2009-10-01 : 11
2009-10-02 : 6
2009-10-03 : 19
..and so on

…which I can plot on some nice chart and show to important people. I would very much prefer a Linq2SQL query as that is what we are currently using for data access, but if I’m out of luck I may be able to go with some raw SQL (accessed via stored procedure, but I would really, really, really prefer Linq2SQL).

(As a bonus my next step will very likely be qualifying which sessions should be included by filtering on some of the other meta data)

Hoping that someone clever will help me out here…

  • 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-12T16:52:57+00:00Added an answer on May 12, 2026 at 4:52 pm

    I would use something like this.

    var result = data.OrderBy(x => x.SessionStarted)
        .GroupBy(x => x.IPAddress)
        .Select(x => x.First())
        .GroupBy(x => x.SessionStarted.Date)
        .Select(x => new { Date = x.Key, New = x.Count() });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This should be totally simple but I can't get it working no matter what
I must be doing something totally stupid here, but I can't get the PLCrashReporter
This question comes from here but can be a totally independent question. I have
I am totally at a loss here and can't find a solution to this
Am I totally missing something here? Why can't I get out what I'm putting
I am probably totally missing the point here but.... How can I pass a
Totally confused here. I have a PARENT UIViewController that needs to pass an NSMutableArray
Is there any function or something like that by which I can create totally
Can you add to dijit widgets that dojango creates without having to totally overwite
Hope someone can help me with this, it has me totally stumped My application

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.