Wednesday, March 28, 2012

one column DISTINCT on 2 Tables

hello I am trying to get a distinct on one column and 2 tables but it doesnt work

Table1
ID_Table1
Name1
Number1

Table2
ID_Table2
ID_Table1
Name2

I want to get : ID_Table1, DISTINCT(Name1), Name2
WHERE Name1 LIKE 'A%'

how can I do it ?

thank youDISTINCT is not a function

does your query join these tables?

could you show your actual query please?|||yes of course the 2 tables are JOIN by Table1.ID_Table1 AND Table2.ID_Table1|||and you want one result row per value of Name1, correct?

okay, here is one way --select Table1.Name1
, min(Table1.ID_Table1)
, max(Table2.Name2)
from Table1
inner
join Table2
on Table2.ID_Table1 = Table1.ID_Table1
where Table1.Name1 like 'A%'
group
by Table1.Name1|||it works fine !

thanks again !

No comments:

Post a Comment