Solved

Count max(date)

Posted on 2009-07-16
5
292 Views
Last Modified: 2013-11-11
Need help with a linq query

                var bpa = from ga in dbg.Stats
                          where ga.UId == usr
                            && ga.Date >= dBegin && ga.Date < dEnd
                          group ga by new { ga.Date.Day } into gr
                          select new
                          {
                              name = gr.Key.Day,
                              value = gr.Max(z => z.Date)
                          };

But "value" gets a date, the "value" should contain the total count of hits with that date.

Thank's in advanced
0
Comment
Question by:dingir
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 1

Author Comment

by:dingir
ID: 24867801
Rising pooints because it's important.
0
 
LVL 12

Expert Comment

by:GuitarRich
ID: 24867811
try changing the max to count
0
 
LVL 1

Author Comment

by:dingir
ID: 24867922
Thank's but i need to take the latest date for each result.

the table looks like
Date               UId
2009-01-01    10
2009-01-05    10
2009-01-04    10
2009-01-01    8
2009-01-01    10
2009-01-04    7
2009-01-02    4
2009-01-03    9

I need a query that takes all 2009-01-05 and count those results.
Which means result:
topdate count
2009-01-01 3
2009-01-02 1
2009-01-03 1
2009-01-04 2
2009-01-05 1

0
 
LVL 1

Author Comment

by:dingir
ID: 24868243
Whatever and however I describe it. I need a query like this (this is a new another school sample taken from web)

   var categories =
      from p in products
      group p by p.Category into g
      select new {
           Category = g.Key,
           MostExpensivePrice = g.Max(p => p.UnitPrice)
      };

...that returns the count of existing "g.Max(p => p.UnitPrice)". Not the latest date itself.
0
 
LVL 15

Accepted Solution

by:
jinal earned 450 total points
ID: 24870147

var bpa = from ga in dbg.Stats
                          where ga.UId == usr
                            && ga.Date >= dBegin && ga.Date < dEnd
                          group ga by new { ga.Date.Day } into gr
                          select new
                          {
                              name = gr.Key.Day,
                              value = gr.Count()
                          };

Open in new window

0

Featured Post

Is Your Team Achieving Their Full Potential?

74% of employees feel they are not achieving their full potential. With Linux Academy, not only will you strengthen your team's core competencies but also their knowledge of of the newest IT topics.

With new material every week, we'll make sure that you stay ahead of the game.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

622 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question