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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T15:24:43+00:00 2026-06-18T15:24:43+00:00

I have the following SQL Server 2008 table: ID Destination Last Result 01 (555)

  • 0

I have the following SQL Server 2008 table:

ID    Destination     Last Result
01    (555) 319-5170  Disconnect
02    (555) 319-5170  Duplicate
03    (555) 319-5170  Duplicate
04    (555) 261-5000  Duplicate
05    (555) 261-5000  Duplicate
06    (555) 261-7325  Busy
07    (555) 261-7325  Duplicate
08    (555) 261-7345  No Answer
09    (555) 261-7345  Duplicate

My goal is to dynamically set the ‘Last Result’ column for all matching phone numbers. So, in the example table above for Destination((555) 319-5170), the result for all matching phone numbers(555) 319-5170) with the value ‘Disconnect’. The sample update statement is below:

    UPDATE C
    SET [Last Result] = (
    SELECT Destination
                FROM Call
                WHERE [Last Result] NOT IN ('Duplicate','No Phone #')
                GROUP BY Destination
                HAVING COUNT(Destination) > 1)
    FROM Call C
    INNER JOIN
            (
                SELECT Destination
                FROM Call
                WHERE [Last Result] NOT IN ('Duplicate','No Phone #')
                GROUP BY Destination
                HAVING COUNT(Destination) > 1
            ) Dup ON Dup.Destination = C.Destination
    WHERE C.[Last Result] NOT IN ('Duplicate','No Phone #')

But I am getting an error:

Msg 512, Level 16, State 1, Line 1
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.

**EXPECTED OUTPUT**:

ID    Destination     Last Result
01    (555) 319-5170  Disconnect
02    (555) 319-5170  Disconnect
03    (555) 319-5170  Disconnect
04    (555) 261-5000  Duplicate
05    (555) 261-5000  Duplicate
06    (555) 261-7325  Busy
07    (555) 261-7325  Busy
08    (555) 261-7345  No Answer
09    (555) 261-7345  No Answer

Thanks in advance for any assistance with a possible solution.

  • 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-06-18T15:24:44+00:00Added an answer on June 18, 2026 at 3:24 pm

    You can look up the first Last Result with the row_number() window function. However, there has to be a way to define “first”. In the example, I’m assuming you have an identity column:

    update  t1
    set     [Last Result] = t2.[Last Result]
    from    Table1 t1
    join    (
            select  row_number() over (partition by Destination
                                       order by Id) as rn
            ,        *
            from     Table1
            ) t2
    on      t1.Destination = t2.Destination
            and t2.rn = 1;
    

    Example at SQL Fiddle.

    If you do not have an identity column, please update the question with how you define “first”. There could be a CreateDt column for example.

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

Sidebar

Related Questions

In SQL Server 2008 I have a user table like the following: Userid Username
I'm using SQL Server 2008 With this table : and i have the following
I have a SQL Server 2008 table with the following columns: ID = uniqueidentifier
Say, I have the following SQL Server 2008 table with data: CREATE TABLE tbl
I have a following table in SQL Server 2008 database: CREATE TABLE [dbo].[Actions]( [ActionId]
I have the following table in a SQL Server 2008 database with lots of
In SQL Server 2008, I have the following tables: CREATE TABLE samples (SampleID int,
I have the following table in SQL Server 2008: CREATE TABLE tbl (ID INT,
I have a SQL Server 2008 R2 table with the following Schema DECLARE @AttributeTable
Let's say I have the following table in SQL Server 2008: ProfileID int //identity;

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.