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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:55:52+00:00 2026-05-13T14:55:52+00:00

I have an SQL Table which consists of 1 column only Column Name A

  • 0

I have an SQL Table which consists of 1 column only

Column Name
A 
A
A
B
B
B
B
C
D
D
E

I need an SQL Code that returns the cut points. For the table above, it will return this:

Column Name
    3
    7
    8
    10
    11

3 is the end of A’s and 7 is the end of B’s and 8 is the end of C’s and so on…

Let’s see what can you come up with :=)

  • 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-13T14:55:52+00:00Added an answer on May 13, 2026 at 2:55 pm

    Assuming the data can be sorted on your Column, the plan is to generate a row number for each row and do a group by to retrieve your data points.

    SQL Server 2000

    DECLARE @YourTable TABLE (Col VARCHAR(1))
    CREATE TABLE #TempTable (ID INTEGER IDENTITY(1, 1), Col VARCHAR(1))
    
    SET IDENTITY_INSERT #TempTable OFF
    INSERT INTO @YourTable (Col) VALUES ('A')
    INSERT INTO @YourTable (Col) VALUES ('A')
    INSERT INTO @YourTable (Col) VALUES ('A')
    INSERT INTO @YourTable (Col) VALUES ('B')
    INSERT INTO @YourTable (Col) VALUES ('B')
    INSERT INTO @YourTable (Col) VALUES ('B')
    INSERT INTO @YourTable (Col) VALUES ('B')
    INSERT INTO @YourTable (Col) VALUES ('C')
    INSERT INTO @YourTable (Col) VALUES ('D')
    INSERT INTO @YourTable (Col) VALUES ('D')
    INSERT INTO @YourTable (Col) VALUES ('E')
    
    INSERT INTO #TempTable
    SELECT      *
    FROM        @YourTable
    ORDER BY    Col
    
    SELECT    MAX(ID)
    FROM      #TempTable
    GROUP BY  Col
    
    DROP TABLE #TempTable
    

    SQL Server 2005

    DECLARE @Table TABLE (Col VARCHAR(1))
    
    INSERT INTO @Table VALUES ('A')
    INSERT INTO @Table VALUES ('A')
    INSERT INTO @Table VALUES ('A')
    INSERT INTO @Table VALUES ('B')
    INSERT INTO @Table VALUES ('B')
    INSERT INTO @Table VALUES ('B')
    INSERT INTO @Table VALUES ('B')
    INSERT INTO @Table VALUES ('C')
    INSERT INTO @Table VALUES ('D')
    INSERT INTO @Table VALUES ('D')
    INSERT INTO @Table VALUES ('E')
    
    
    SELECT  MAX(RowNumber)
    FROM    (SELECT RowNumber = ROW_NUMBER() OVER (ORDER BY Col), Col
             FROM   @Table) t
    GROUP BY Col
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a column in SQL table which would have data like this: College:
I have a sql table and I have a column which includes data such
I have a SQL table called StudentMarks.which consist of StudentID,SubjectName,SubjectMark I want to write
I have a SQL table with three columns X, Y, Z. I need to
I want a table which can only have one record. My current solution is:
I have a table which have an integer coloumn. Let table name is Table1
I have sql stored procedure which pass and return some values: CREATE PROCEDURE [dbo].[GetMoney]
I have an audit table which stores audit rows for a long running process
I have an MS Access 2003 mdb and mdw which is connected to a
(related to Finding the lowest unused unique id in a list and Getting unused

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.