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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:23:45+00:00 2026-06-12T00:23:45+00:00

I have created a the following view in my Database after combining multiple tables.

  • 0

I have created a the following view in my Database after combining multiple tables. A select * from MYViEW gives the following result below.

ProductID | TechID | ContactID | Priority | FIRSTNAME | MIDDLEINI | LASTNAME | 
1123         2406       1371        1        Pradeep       X          Nayak      
1123         2406       1368        2        Hello         W          World      
1123         2406       1363        3        Foo           Y          World    
1299         2279       1208        2        Some          Z          Dude     

And I need the OUTPUT result to below to be displayed:

ProductID | TechID | ContactID | Priority | FIRSTNAME | MIDDLEINI | LASTNAME | Buyers                                        |
1123         2406       1371        1        Pradeep    X           Nayak      Nayak, Pradeep X; World, Hello W; World, Foo Y  
1299       2279         1208        2        Some       Z           Dude       Dude, Some Z

For every Product ID and Tech ID have a single record, and all the Buyers must be combined in a column in the format LastName, FirstName MiddleIni and each name separated by a space. I have already tried to use the custom aggregate function from here for combing the results to a single column. Please let me know if you can help me with a query for this.

  • 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-12T00:23:46+00:00Added an answer on June 12, 2026 at 12:23 am

    This will display the data in the manner than you want:

    select t1.ProductID,
      TechId,
      x.ContactID,
      x.Priority,
      FirstName,
      MiddleIni,
      LastName,
      stuff((select  '; ' + lastname + ', ' + FIRSTNAME + ' ' + MIDDLEINI
              from yourtable t2
              where t2.productid = t1.productid
            FOR XML PATH('')), 1, 1, '') 
    from yourtable t1
    inner join
    (
      select min(priority) priority, ProductID, max(ContactID) ContactID
      from yourtable
      group by ProductID
    ) x
      on t1.ProductID = x.ProductID
      and t1.contactid = x.contactid
    

    see SQL Fiddle with Demo

    This is getting the MIN() priority value – the highest – and then the MAX() contactId

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

Sidebar

Related Questions

I have created an alert view with two buttons using the following code: UIAlertView
I have created the following view for users to create new items. Ive tried
I created dataset that contains Table View from SqlServer 2008 database. Then I created
I have the following code to create my window, my view and my sub
If i have a controller action Create that returns a view with the following
In my rails view(index.html.erb), i have following structure <div> <%= render :partial => create
I have created following rule in the .htaccess file located at the root of
I have created following thing in android using android compatibility support package Basically i
I need to have the URL like photos/13/rate => I have created following routing
I have created the following class class Contact def initialize(id, name, phone) @id =

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.