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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T00:29:18+00:00 2026-05-24T00:29:18+00:00

In my database I have a list of data Name Value a/b/c 1 a/b/c/d

  • 0

In my database I have a list of data

Name Value

a/b/c     1
a/b/c/d   1
a/b/c/d/e 1
b/b/c     1
b/b/c/d   2
c/c/d     3
c/c/d/e   4
d/d       5

if I set max length 3 I want to get

a/b/c  3
b/b/c  3
c/c/d  7
d/d    5

How can I do this?

CREATE TABLE dataTable (
ID                          BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
Name                        VARCHAR(255),
Value                       INT
) ENGINE=InnoDB;


INSERT INTO dataTable (Name, Value) VALUES ("a/b/c", 1), ("a/b/c/d", 1), ("a/b/c/d/e", 1), ("b/b/c", 1), ("b/b/c/d", 1), ("c/c/d", 1), ("c/c/d/e", 1),  ("d/d", 1);
  • 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-24T00:29:19+00:00Added an answer on May 24, 2026 at 12:29 am
    SELECT LEFT(Name, 5) AS Name, SUM(Value) as TotalValue
        FROM dataTable
        GROUP BY LEFT(Name, 5)
    

    Obviously, I hard-coded the 5 in my example, but you could do a variable like (2*MaxLen-1).

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

Sidebar

Related Questions

I have a list of e-mails from one database which I want to check
I have 2 tables in database:tbleducation,tblemployee.Anyway for table tblemployee, I have fields: employeeID,employeeName....I want
In my database I have a list of cases: { Id: 1, Owner: guid1,
I have a list of ordered objects stored in the database and accessed through
I have a list of categories that I publish to a UI from database.
Say I have a list of items from a database. Next to each item
Assume that I have a list of employee names from a database (thousands, potentially
I have a database containing a list of status updates and time stamp. by
I have a database of Employees and a dropdown list which I generated with
have a database with a list of business leads. They are all given a

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.