Try this
SELECT [name],[phone]
FROM (
SELECT *,Row_Number() Over (Partition By phone Order By (Select Null)) AS RN
FROM Table1
) AS T
Where RN = 1
OFFSET n ROWS
You can replace n with your custom values...
Вопрос
I have the following table and want to group by
[name] [phone]
doniking 081222222222
doni 081222222222
Bambang Gentholet 081111111111
Bambang 081111111111
I want to get this result:
[name] [phone]
doniking 081222222222
Bambang Gentholet 081111111111
Решение 2
Try this
SELECT [name],[phone]
FROM (
SELECT *,Row_Number() Over (Partition By phone Order By (Select Null)) AS RN
FROM Table1
) AS T
Where RN = 1
OFFSET n ROWS
You can replace n with your custom values...
Другие советы
Try this
SELECT MAX(name), phone FROM <TableName> group by phone
EDIT: for offset
SELECT MAX(name), phone FROM <TableName> group by phone
order by phone offset 10 rows
FETCH NEXT 5 ROWS ONLY;
Check this for further details.
Try this
SELECT name,
phone
FROM (SELECT *,
Row_number()
OVER(
partition BY phone
ORDER BY name) row_num -- or you can have order by (select null)
FROM table1) t
WHERE row_num = 1