Hi
Trying to get this sql - query to run under Query Analyzer but not sure how to correct anything in it to the right
______INFO_______
Table : iptable
Fields : ip_start, ip_end, location
Table : PageLog
Fields : pl_ipaddress, pl_sessionid, pl_remotehost
_________________
______________CODE_______________
select
iptable.location
, count(pl_ipaddress)
from (
select distinct
pl_sessionid
, pl_ipaddress
, pl_remotehost
from PageLog
where pl_datetime
between '2003-12-25 00:00:00'
and '2003-12-25 23:59:59'
and pl_ipaddress <> ''
) as dt_pagelog
inner
join iptable
on dt_pagelog.pl_ipaddress
between iptable.ip_start
and iptable.ip_end
group
by iptable.location
order
by count(pl_ipaddress) desc
___________END CODE_________________
1) If i run this i get :
--> "Column dt_pagelog.pl_ipaddress is invalid in the select list because it's not contained in a aggregate function or in the GROUP BY clause.
2) If i include it in the GROUP BY i get :
--> The text, ntext and image datatypes cannot be used in WHERE, HAVING or ON clause, except with the LIKE or IS NULL predicate.
Soo.. how on earth should i put this right to get to use it with a INNER JOIN, since that has to have a ON to it ?
Not very familiar with INNER JOIN's so any help will be very much appreciated..
Best regards
Mirador.