How to use like in grouped columns

1

I'm trying to find the rows that start with Au but the sql server is reporting an error when using the Description with the like it says: Ambiguous column name 'Description'.

Select A.NotesID, Coalesce( A.Description, B.Description ) as Description 
from MdPrNotes A Left Outer Join MDBIOPSYCHOSOCIALSETUPHDR B On
A.NoteCode = B.BioCode
Where Status = 'A' AND CanPatientEditIt = 'Y' AND Description like '%Au%' 
order by Description
    
asked by Raidel Fonseca 29.10.2018 в 20:58
source

1 answer

3

The problem is that you do not know which column to order, since there are two "description" fields.

Try doing it like this:

SELECT A.NotesID, Coalesce( A.Description, B.Description ) as Description 
FROM MdPrNotes A Left Outer Join MDBIOPSYCHOSOCIALSETUPHDR B On
A.NoteCode = B.BioCode
WHERE Status = 'A' AND CanPatientEditIt = 'Y'
  AND Coalesce(A.Description, B.Description) like '%Au%' 
ORDER BY Coalesce(A.Description, B.Description)

Good luck!

    
answered by 29.10.2018 / 21:01
source