Return max repeated item in list

Not the absolutely most efficient, but it works: var maxRepeatedItem = prod.GroupBy(x => x) .OrderByDescending(x => x.Count()) .First().Key; This is more efficient: var maxRepeatedItem = prod.GroupBy(x => x) .MaxBy(x => x.Count()) .First().Key; but it requires MoreLinq‘s extension MaxBy EDIT (as per comment) : If you want all the max repeated elements in case of ties, … Read more

How do I speed up counting rows in a PostgreSQL table?

For a very quick estimate: SELECT reltuples FROM pg_class WHERE relname=”my_table”; There are several caveats, though. For one, relname is not necessarily unique in pg_class. There can be multiple tables with the same relname in multiple schemas of the database. To be unambiguous: SELECT reltuples::bigint FROM pg_class WHERE oid = ‘my_schema.my_table’::regclass; If you do not … Read more

How to count cells in a range with a value less than another cell in excel?

You can use XL4 macros (Excel formula) to count up cells with different backcolor or even font colour in excel 🙂 See this LINK. For Font color the type_num is 24. And for backcolor we will use 63 Open the Name Manager Give a name. Say BackColor Type this formula in Refers To =GET.CELL(63,OFFSET(INDIRECT(“RC”,FALSE),-1,0)) and … Read more