title: Get url part only in SQL Server
body: <p>My table data is looks like:</p>
  
  <pre><code>SessionRefere  
  
  http://www.google.com/url?sa=t&amp;rct=j&amp;q=aaa bbb&amp;source=web&amp;cd=1&amp;cad=rja&amp;sqi=2&amp;ved=0CB4QFjAA&amp;url=http://www.abc.com/&amp;ei=QFR0UM-JKIrQrQfsuoG4CQ&amp;usg=AFQjCNExYcKkcvobBbktLGNksptf1giQRw
  -------------------------------------------------
  http://www.google.com/reader/view/?hl=es&amp;tab=Xq&amp;at=RTknd_lBUUnvNqan2641EA
  ----------------------------------------------------
  http://www.google.com/url?sa=t&amp;rct=j&amp;q=&amp;esrc=s&amp;source=web&amp;cd=5&amp;cad=rja&amp;ved=0CEgQFjAE&amp;url=http://www.abc.com/ppp.aspx&amp;ei=dmd0UOO9AYnY4QS1sYGwBw&amp;usg=AFQjCNGIFcJUUSVpl_ZiZoSWDP2LkIagtw
  </code></pre>
  
  <p>It's only sample data.There are many cases like this. So I want original url part before count.</p>
  
  <p>I use this query to get data.</p>
  
  <pre><code>DECLARE @temp table(RefPage nvarchar(200))
  insert into @temp
  SELECT
     CASE CHARINDEX( '?', SessionReferer)
         WHEN 0 THEN SessionReferer
         ELSE LEFT(SessionReferer, CHARINDEX( '?', SessionReferer) - 1) END AS RefPage 
  FROM Tracker WHERE [start] between '1-1-2010' and '1-1-2015' and  SessionReferer&lt;&gt; ''
  
   select distinct RefPage, count(*) as [VisitTime] from @temp
    group by RefPage
  order by [VisitTime] desc
  </code></pre>
  
  <p>and my result is:</p>
  
  <pre><code>SessionRefere                           VisitTime
  http://www.google.com/url                 2
  http://www.google.com/reader/view/        1 
  </code></pre>
  
  <p>But I want a result:</p>
  
  <pre><code>SessionRefere                           VisitTime
  http://www.google.com                      3
  </code></pre>
  
  <p>Is it possible to get desire result or I am in wrong way? Thanks.</p>