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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:36:18+00:00 2026-06-16T00:36:18+00:00

var data = new[] { new { Id = 0, Cat = 1, Price

  • 0
var data = new[] {
 new { Id = 0, Cat = 1, Price = 2 },
 new { Id = 1, Cat = 1, Price = 10 },
 new { Id = 2, Cat = 1, Price = 30 },
 new { Id = 3, Cat = 2, Price = 50 },
 new { Id = 4, Cat = 2, Price = 120 },
 new { Id = 5, Cat = 2, Price = 200 },
 new { Id = 6, Cat = 2, Price = 1024 },
};

var ranges = new[] { 10, 50, 100, 500 };

Needed output is grouped price count by equal or greater than the range used according categories.
(in one linq statement)

cat    range       count
-------------------------------------
1       10           2    (In 1. categories there is 2 item that price >= 10(range) [10;30]) 
2       10           4    (In 2. categories there is 4 item that price >= 10(range) [50;120;200;1024]) 
2       50           4    ....
2      100           3    ....
2      500           1    (In 2. categories there is 1 item that price >= 500(range) [1024]) 
  • 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-16T00:36:19+00:00Added an answer on June 16, 2026 at 12:36 am

    Try this:

    var data = new[] {
     new { Id = 0, Cat = 1, Price = 2 },
     new { Id = 1, Cat = 1, Price = 10 },
     new { Id = 2, Cat = 1, Price = 30 },
     new { Id = 3, Cat = 2, Price = 50 },
     new { Id = 4, Cat = 2, Price = 120 },
     new { Id = 5, Cat = 2, Price = 200 },
     new { Id = 6, Cat = 2, Price = 1024 },
    };
    
    var ranges = new[] { 10, 50, 100, 500 };
    
    var result = from r in ranges
            from g in data
            where g.Price >= r
            select new {g.Cat, Price=r};
    
    var groupedData = 
            from d in result
            group d by new{d.Cat, d.Price} into g
            select new{Cat=g.Key.Cat, Price=g.Key.Price, TotalCount=g.Count()};
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My flash code: var request=new URLRequest('http://localhost/test.php'); request.method = URLRequestMethod.POST; var data = new URLVariables();
Code example: <script> var data = new Array(); data[0] = 'hi'; data[1] = 'bye';
I have data like the following: var data = [{ id: 1, date: new
public string Process<T>(string name, string address) { var dataObj= new Data<T>(); List<T> currentList= dataObj.GetAll(name);
This is my code : DataClassesDataContext data = new DataClassesDataContext(); var hey = from
$.each(data, function () { var d = new Date(item.created_at.replace('+', 'UTC+')); var dd = d.format('mediumDate');
var array1 = {}; array1['one'] = new Array(); array1['one']['data'] = 'some text'; array1['one']['two'] =
when handling data, i always have to write the following: var dataSourceRequest:URLRequest = new
Why does this code always return 0? var possibleMatches = new Array(); $.getJSON('getInformation.php', function(data)
containerBuilder .Register<IGraphClient>(context => { var graphClient = new GraphClient(new Uri(http://localhost:9999/db/data)); graphClient.Connect(); // Particularly this

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.