I have several records (bills) that are basically duplicates of each other, except for one field, which represents the language that bill is in.
For example:
<Probably the easiest way would be to use ROW_NUMBER
and PARTITION BY
SELECT * FROM (
SELECT b.*,
ROW_NUMBER() OVER (PARTITION BY BillID ORDER BY Lang) as num
FROM Bills b
WHERE Account = 'abcd'
) tbl
WHERE num = 1
Use SELECT DISTINCT keyword to get different values
SELECT DISTINCT ID,BillID,Account,Name,Amount,Lang
FROM Bills;
You will get different values.
select
BillID,Account,Name,Amount,max(Lang)
FROM Bills
WHERE Account='abcd'
group by BillID,Account,Name,Amount;
Same as user2407394 except without the ID in the groupby, since that would return 3 too.
select
ID,BillID,Account,Name,Amount,max(Lang)
FROM Bills
WHERE Account='abcd'
group by BillID,Account,Name,Amount;
Given that you are not giving priority to any specific language if there is same bill in multiple languages. The above query will work perfect.
EDIT : Removed "ID" from group by. @Phil You are right..!!