We help IT Professionals succeed at work.

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

newtoperlpgm
newtoperlpgm asked
on
82 Views
Last Modified: 2017-03-13
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.
Comment
Watch Question

Vitor Montalv√£oIT Engineer
CERTIFIED EXPERT
Distinguished Expert 2017

Commented:
We need to know the structure of your tables to help you.
How do you relate Notes with the Person?

Author

Commented:
So sorry, I join the Notes table to Person on PersonID.
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
That worked for me.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.