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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:27:52+00:00 2026-05-23T19:27:52+00:00

I have a database table with a field that has values such as AAAA

  • 0

I have a database table with a field that has values such as

AAAA
BBBB0001
BBBB0002
CCCC
CCCC
CCCC

and I would like to know how many AAAAs, BBBBs and CCCCs there are (1, 2 and 3 here).

If I set up a couple of test queries in LinqPad with those values in an array:

var Table = new [] {"AAAA", "BBBB1", "BBBB2", "CCCC", "CCCC", "CCCC"};

var query1 = Table.GroupBy(d => d).Select( g => new { K = g.Key, C = g.Count()});
query1.Dump();

var query2 = Table.GroupBy(d => d.Substring(0, 4)).Select( g => new { K = g.Key, C = g.Count()});
query2.Dump();

then I get the results I expect – in the first case grouped by the key and in the second grouped by the first four characters of the key

AAAA    1
BBBB1   1
BBBB2   1
CCCC    3

AAAA    1
BBBB    2
CCCC    3

which is fine. But if replace the array by a SQLite table and run the same queries, what I get is

AAAA    1
BBBB1   1
BBBB2   1
CCCC    3

AAAA    1
BBBB    1
BBBB    1
CCCC    3

That is, the first is correct, while in the second, the field is being correctly shortened but the grouping is wrong.

Anyone cast any light on this?

Andrew

  • 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-23T19:27:54+00:00Added an answer on May 23, 2026 at 7:27 pm

    What connector are you using for your linq to sqlite? It feels like it’s likely to be a bug in that connector.

    e.g. Looking at the revision table for dotconnect – http://www.devart.com/dotconnect/sqlite/revision_history.html – then there are plenty of group by bugs that they’ve found and fixed in recent months – and I’m sure there could be others in there.


    Unless you absolutely need sqlite, then you could consider switching to SQL CE – in which case you’d get more direct support for Linq from Microsoft.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a SQL database that has a table with a field set to
I have a database structure that has a Person table which contains fields such
I currently have a MySQL database with a table that has a field that
I have a sqlite table that has amount field with NUMERIC(10,5) value(I know data
I have a database table with a field that I need to read from
I have a database that accepts no null values and has a default for
So I have a database that has a structure something like this: [user_table] user_id,
I have a database table TravelRequest that contains, amongst other things, the fields SignOffName
I have a table in database that is having some fields one of which
i have some fields in my database table,and a field with phone name ,

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.