If I understand you needs correctly what about this. create table #test_table
(KW varchar(100),LP varchar(100))
insert into #test_table
select 'cat' as KW, '/catpage' as LP
insert into #test_table
select 'bigcat' as KW, '/catpage' as LP
insert into #test_table
select 'furrycat' as KW, '/catpage' as LP
insert into #test_table
select 'dog' as KW, '/dogpage' as LP
insert into #test_table
select 'bigdog' as KW, '/dogpage' as LP
insert into #test_table
select 'pets' as KW, '/' as lp
SELECT lp, kw
FROM #test_table tt
GROUP BY LP, KW
ORDER BY LP
DROP TABLE #test_table
***SQL born on date Spring 2013:-)