Avatar of newtoperlpgm
newtoperlpgmFlag for United States of America

asked on 

SQL Server How-To Show Notes In First Row of Results

I have a simple query that joins six tables to retrieve the desired data on PersonID.  I need to include Notes from a separate Notes table.  I only want the notes to appear once in the result set, how can I achieve that?  In the data, I join the Notes table and Table1 on PersonID.  I only want to show Note1 in the data set below on row 1 IF the Notes are the same, as in the example.  If the Notes are different, for example where it is Note2, then I want to display it in my query.   The sample of data is below:
PersonID     Name     Address     Phone     Email    AcctNumber     SomeDate     EndDate    ExpensePayment     Notes
12345          Joe           123 Yam    55555     a@b.com 123999          02/02/2017    03/04/2017    27.99                     Note1
12345          Joe            123 Yam   55555     a@b.com  12399           02/02/2017    05/23/2017    15.23                     Note1
12345          Joe            123 Yam   55555     a@b.com   12399          04/03/2017    04/04/2017     5.99                      Note2

Thank you.
Microsoft SQL Server

Avatar of undefined
Last Comment
newtoperlpgm
Avatar of Vitor Montalvão
Vitor Montalvão
Flag of Switzerland image

We need to know the structure of your tables to help you.
How do you relate Notes with the Person?
Avatar of newtoperlpgm
newtoperlpgm
Flag of United States of America image

ASKER

So sorry, I join the Notes table to Person on PersonID.
ASKER CERTIFIED SOLUTION
Avatar of Shalu M
Shalu M
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
Avatar of newtoperlpgm
newtoperlpgm
Flag of United States of America image

ASKER

That worked for me.
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