Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
BennoM1984
Starting Member
4 Posts |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2011-11-11 : 07:54:50
|
| for the domain select domain = left(url,charindex('/',url) from urllistto get one of eachselect* from (select domain = left(url,charindex('/',url), url, ROW_NUMBER() over (psartition by left(url,charindex('/',url), order by newid())from urllist) awhere seq = 1==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
eralper
Yak Posting Veteran
66 Posts |
Posted - 2011-11-11 : 08:09:01
|
Hello Benno,Please try the following SELECT statementActually it has the same structure with nigel's solutionBut I'm using a udf for extracting domain from URLYou can find the function here :[url]http://www.kodyaz.com/articles/how_to_parse_url_for_domain_name.aspx[/url]with cte as ( select url, dbo.Parse_For_Domain_Name(url) domain from URL_LIST )select urlfrom ( select row_number() over (partition by domain order by newid()) rn, url from cte) twhere rn = 1 I hope it helps-------------Eralperhttp://www.kodyaz.com |
 |
|
|
BennoM1984
Starting Member
4 Posts |
Posted - 2011-11-11 : 08:14:33
|
| wow, fast reply, thxbut i got the following error:#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' url, ROW_NUMBER() over (psartition by left(url,charindex('/',url), order by new' at line 2 |
 |
|
|
BennoM1984
Starting Member
4 Posts |
Posted - 2011-11-11 : 08:17:56
|
| @ eralperthanx for fast reply, but i like to use the query from php, so i dont know how to implement sql functions...it would be easier for me to use a select statement...thanx |
 |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2011-11-11 : 08:27:14
|
| Try a MySQL site rather than a SQL Server site?==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
BennoM1984
Starting Member
4 Posts |
Posted - 2011-11-11 : 08:32:42
|
| user knowledge is better here i think.. |
 |
|
|
|
|
|
|
|