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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:30:56+00:00 2026-05-16T18:30:56+00:00

dear all..i have some data at DB. name Range bla 123×9901-123×0000 //it means range

  • 0

dear all..i have some data at DB.

name        Range
bla     123x9901-123x0000      //it means range 9901 until 10000 = 100
bla     123v0001-123v0100      // 10001-10100 = 100

i want the result like:

   name         Qty  
   bla          200

i counting them use:

SELECT................
      IF(RIGHT(Range,4) = "0000",10000,RIGHT(Range,4)) - MID(Range,5,4) + 1 AS Qty
FROM mytable GROUP BY name;

but the result:

name      Qty
bla       100
  • 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-16T18:30:56+00:00Added an answer on May 16, 2026 at 6:30 pm

    Use:

      SELECT name,
             SUM(IF(RIGHT(Range,4) = "0000",10000, RIGHT(Range,4)) - MID(Range,5,4) + 1) AS Qty
        FROM mytable
    GROUP BY name;
    

    …gives me:

    name    Qty  
    -------------
    bla     200
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

dear all, i'll take some data from the database. and join two tables.the code
dear all..i have this data inside DB: line model serial fa01 kd-g335ud 105x0001 fa01
dear all..i have a table it looks like: Name version DDX 01 DTX 05
Dear all, I have a data frame which comes directly from a sensor. The
dear all. i have a lot of data in my database. after that i
Dear all,Now i have this question in my java program,I think it should be
Dear all, I have a question about Facebook Page: ( NOT user profile page,
Dear all, I have a select query that currently produces the following results: DoctorName
Dear All, please help me since I'm newbie in SQL Server. I have a
dear all..i have this code: <script> var str=KD-R435MUN2D; var matches=str.match(/(EE|[EJU]).*(D)/i); if (matches) { var

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.