title: tracking IP addresses
body: <p>I want to track IP addresses visited my website. I want to know what time and what page they visit. I store ip address in VISITORIP, date entered in DATEENTERED and page URL in HTTPADDRESS columns.</p>
  
  <p>I want to group them by dates. My outcome should be like:</p>
  
  <pre><code>TIME                    PAGE
   7/12/2009
  3:16:27 PM  ?Section=products&amp;SubSection=products&amp;CATEGORYID=1
  2:46:50 PM  ?Section=products&amp;SubSection=products&amp;CATEGORYID=8
  2:20:45 PM  ?Section=products&amp;SubSection=products&amp;CATEGORYID=11
   7/11/2009
  9:34:28 AM  ?Section=products&amp;SubSection=products&amp;CATEGORYID=7
  9:33:31 AM  ?Section=products&amp;SubSection=products&amp;CATEGORYID=2
   7/10/2009
  9:53:16 PM  ?Section=products&amp;SubSection=products&amp;CATEGORYID=9
  9:34:14 PM  ?Section=products&amp;SubSection=products&amp;CATEGORYID=4
  9:27:11 PM  ?Section=products&amp;SubSection=products&amp;CATEGORYID=3
  9:15:47 PM  ?Section=products&amp;SubSection=products&amp;CATEGORYID=15
  </code></pre>
  
  <p>Problem is, I could not group them by dates. I get the outcome as:</p>
  
  <pre><code>07/12/2009
  7/12/2009 3:16:27 PM    /html/default.aspProcess=HomeNewSeason&amp;IMAGECONTENT=bg_home_newtaste.gif
  7/12/2009 3:16:27 PM    /html/default.aspProcess=HomeBestSeller&amp;IMAGECONTENT=bg_home_customerschoice.gif
  07/12/2009
  7/12/2009 3:16:27 PM    /html/default.aspProcess=HomeNewSeason&amp;IMAGECONTENT=bg_home_newtaste.gif
  7/12/2009 3:16:27 PM    /html/default.aspProcess=HomeBestSeller&amp;IMAGECONTENT=bg_home_customerschoice.gif
  07/09/2009
  7/9/2009 5:37:02 PM     /html/default.aspSection=checkout
  07/09/2009
  7/9/2009 5:37:02 PM     /html/default.aspSection=checkout
  07/09/2009
  7/9/2009 5:37:02 PM     /html/default.aspSection=checkout
  </code></pre>
  
  <p>My codes:</p>
  
  <pre><code>&lt;%
          Case "TrackIP"
  
          IPADDRESS = Request.QueryString("IPADDRESS") 
  
      SQL = "SELECT CONVERT(VARCHAR(10), DATEENTERED, 101) AS DATEENTERED"
      SQL = SQL &amp; " FROM STATS"
      SQL = SQL &amp; " WHERE VISITORIP = '"&amp; IPADDRESS &amp;"'"
      SQL = SQL &amp; " GROUP BY DATEENTERED" 
      SQL = SQL &amp; " ORDER BY DATEENTERED DESC"
      Set objDateEntered = objConn.Execute(SQL)   
  %&gt;
      &lt;table&gt;
          &lt;thead&gt;
              &lt;tr&gt;
                  &lt;th&gt;Time&lt;/th&gt;
                  &lt;th&gt;Page&lt;/th&gt;
              &lt;/tr&gt;
          &lt;/thead&gt;
          &lt;tbody&gt;
  &lt;% Do While Not objDateEntered.EOF %&gt;
              &lt;tr class="row-title"&gt;
                  &lt;td colspan="2"&gt;&lt;%=objDateEntered("DATEENTERED")%&gt;&lt;/td&gt;
              &lt;/tr&gt;
  &lt;%
      SQL = "WITH LASTVISIT AS ("
      SQL = SQL &amp; " SELECT VISITORIP, MAX(DATEENTERED) AS DATEENTERED"
      SQL = SQL &amp; " FROM STATS"
      SQL = SQL &amp; " WHERE VISITORIP = '"&amp; IPADDRESS &amp;"' AND CONVERT(VARCHAR(10), DATEENTERED, 101) = CONVERT(VARCHAR(10), '"&amp; objDateEntered("DATEENTERED") &amp;"', 101)"
      SQL = SQL &amp; " GROUP BY VISITORIP"
      SQL = SQL &amp; " )"
      SQL = SQL &amp; " SELECT STATS.VISITORIP, STATS.HTTPADDRESS, STATS.DATEENTERED"
      SQL = SQL &amp; " FROM STATS"
      SQL = SQL &amp; " INNER JOIN LASTVISIT"
      SQL = SQL &amp; " ON LASTVISIT.VISITORIP = STATS.VISITORIP AND LASTVISIT.DATEENTERED = STATS.DATEENTERED"
      SQL = SQL &amp; " ORDER BY STATS.DATEENTERED DESC"
      Set objTrackIP = objConn.Execute(SQL)   
  %&gt;
  &lt;% Do While Not objTrackIP.EOF %&gt;
              &lt;tr class="row-a"&gt;
                  &lt;td&gt;&lt;%=objTrackIP("DATEENTERED")%&gt;&lt;/td&gt;
                  &lt;td class=""&gt;&lt;%=objTrackIP("HTTPADDRESS")%&gt;&lt;/td&gt;
              &lt;/tr&gt;
  &lt;%
      objTrackIP.MoveNext
      Loop
  %&gt;
  &lt;%
      objDateEntered.MoveNext
      Loop
  %&gt;
          &lt;/tbody&gt;
      &lt;/table&gt;
  </code></pre>
  
  <p>edit: I think problem is with my outer query. But I grouped them by DATEENTERED field, I dont know what else can I do.</p>