Solved

sql data formatting scenario

Posted on 2014-10-21
3
92 Views
Last Modified: 2014-12-03
hi experts
when i query my table
select Product, Name, Value, Yearly_Amount from Customer_Research
The data i get is something like this
Data from my table
So if you see there are three products MBS,OOK,ZRR. The Name,Value,Yearly_Amount are same for all these products which is
TOM Adjust      60      2772
MAC Inc             20      10406438
SDRF             58      2764
PPLED             89      1

What i am trying to do is to get a result set like this ...    
trying to show / group by multiple column values
So basically trying to group by Name/Value/Yearly_Amount entries and see the products
But that might not be the best way to represent the data, maybe a little confusing to the user perhaps?

This representation woud be best i think
comma seperated grouping
Is it possible to do what i am trying to do?
Any sugessions would be greatly appreciated.
Thanks.
2.png
2.png
2.png
0
Comment
Question by:royjayd
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 50

Accepted Solution

by:
Vitor Montalvão earned 500 total points
ID: 40394503
It looks like you are facing a bad database model design. How can you have a table with repeated values like that?

Instead of giving you a solution for a query, I think it's better to help you to get a normalized database model.
Can you post your table structure and the query that you are using?
Also if it's possible to know how you are insert data in that table (how and where's the data coming from)?
0
 

Author Comment

by:royjayd
ID: 40394689
>>How can you have a table with repeated values like that?

We do have a normalized database model.
That was just a sample sql, i dint want to post the entire query since it contains INNER JOINS on more than 5 tables[The query itself is pretty big]
 I was focussing more on the result set and how to tweak the result set if possible.

Thanks.
0
 
LVL 50

Expert Comment

by:Vitor Montalvão
ID: 40394786
It will be very hard to work with a subset of the data and only with a small part of the query.
I will then suggest you to study the STUFF function together with FOR XML PATH option, since can be what you are looking for. Check the example #6 in this article.
0

Featured Post

Comparison of Amazon Drive, Google Drive, OneDrive

What is Best for Backup: Amazon Drive, Google Drive or MS OneDrive? In this free whitepaper we look at their performance, pricing, and platform availability to help you decide which cloud drive is right for your situation. Download and read the results of our testing for free!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SQL Recursion 6 49
Enabled trace flag 4135 or 4199 - SQL SERVER 2 34
Checking for column changes SQL 2014 4 42
Need to trim my database size 9 53
There have been several questions about Large Transaction Log Files in SQL Server 2008, and how to get rid of them when disk space has become critical. This article will explain how to disable full recovery and implement simple recovery that carries…
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question