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

  • Home
  • SEARCH
  • 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 7409699
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:07:22+00:00 2026-05-29T06:07:22+00:00

My output is not as I expected, what i want is eliminated duplicated data.

  • 0

My output is not as I expected, what i want is eliminated duplicated data. i tried to use group by and distinct before but it doesn’t work.=(

data in my database

who are u?   A
who are u?   B
who are u?   C
who am i?    A
who am i?    B
who am i?    C

current output

Column ‘ExerciseTable.r1’ is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.

expected output

who are u? A
           B
           C

Who am i?  A
           B
           C

<asp:SqlDataSource ID="SqlDataSource2" runat="server" 
 ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
 SelectCommand="SELECT [Question],[r1] FROM [ExerciseTable] GROUP BY [Question]">

</asp:SqlDataSource>
  • 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-29T06:07:23+00:00Added an answer on May 29, 2026 at 6:07 am

    In your SQL Statement(c1 first column, c2 second column) :

    Select 
    case when t.[RN]>1 and t.[RN]<>4 then  '' else t.c1 end [c1],
    t.c2 from
    (
    Select ROW_NUMBER() OVER (ORDER BY c1) AS [RN],c1,c2 from t1
    ) as t
    

    Without a fixed RowNumber (t.[RN]) :

    Select 
    case 
    when 
    t.[RN]=( 
        Select min([RN]) from
        (
        Select  ROW_NUMBER() OVER (ORDER BY c1)  AS [RN],c1,c2 from t1 
        ) as t where c1='who am i?'
    )   
    or 
    t.[RN]=(
        Select min([RN]) from
        (
        Select  ROW_NUMBER() OVER (ORDER BY c1)  AS [RN],c1,c2 from t1 
        ) as t where c1='who are u?'
    ) then  t.c1 else '' end [c1],
    t.c2 from
            (
            Select ROW_NUMBER() OVER (ORDER BY c1) AS [RN],c1,c2 from t1
            ) as t
    

    Or you can iterate thru the result set (Eg:a List) using C#/VB.Net and remove the data on the column for the following rows after the first one having ‘who am i?’ and the same for ‘who are u?’

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

Sidebar

Related Questions

The first command does work as expected but not the second one. I want
I have this program which does not work as expected. Help me. I want
I want to output Site information form in another place. I tried to use
I want to use the map using JavaScript. I could get the expected output
My LINQ query is not producing the expected output below. Basically, it's the sum
How can I get all this to not only output on the screen, but
Im not sure how to output MySQL data into formats below. (eg: timelist, usersex,
So far I get the expected output, but is it a fluke? Is getTemplate()
I want to have summary of difference between two files. Expected output is count
For some reason I'm not getting the expected output on this curl function, IF

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.