Avatar of Jacque Scott
Jacque ScottFlag for United States of America

asked on 

Query GROUP BY

Each client may have more than one MatterID associated with it.  I would like to display the client name only once.  Can this be done in a query?


Example:

Henry Winkler        555125147
                                  478554425
                                   154895522

Tom Jones               1425784111

Melissa Gilbert        4158234599

Alicia Keys                 9235487444
                                    2233654788


SELECT c.FullName, m.MatterID
FROM CONTACTS C 
JOIN MattersContacts MC ON C.CONTACTS = MC.Contacts 
JOIN MATTERS M ON M.MATTERS = MC.Matters 
JOIN MattersQADVISORS MQA ON M.Matters = MQA.Matters 

Open in new window

Microsoft SQL ServerSQL

Avatar of undefined
Last Comment
Scott Pletcher
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

This is the job of the viewing/reporting tool. SQL is there to spit data!
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

unless you want to concatenate your values into a single field: http://emoreau.com/Entries/Blogs/2009/10/SQL-Concatenate-values-multiple-from-multiple-lines.aspx
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

Éric is correct.  I think the SSRS property name is 'Hide Duplicates', not sure about other reporting applications.

The role of the database is to store and execute queries in a timely manner.
The role of a reporting applicaiton is to take that data and render it in a cosmetically appealing way, and this question is about cosmetics.
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

Oracle expert ststuber has a code solution here, although I'm not a fan of this approach.
ASKER CERTIFIED SOLUTION
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
SOLUTION
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Microsoft SQL Server
Microsoft SQL Server

Microsoft SQL Server is a suite of relational database management system (RDBMS) products providing multi-user database access functionality.SQL Server is available in multiple versions, typically identified by release year, and versions are subdivided into editions to distinguish between product functionality. Component services include integration (SSIS), reporting (SSRS), analysis (SSAS), data quality, master data, T-SQL and performance tuning.

171K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo