Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with Query!

Status
Not open for further replies.

Bernini

Programmer
Oct 26, 2004
98
MT
Hi

I have the following query which retrives the total and percentages of access users had on my site (restricted).

Code:
SELECT concat(U.surname, ' ', U.name) as UNAME, C.name as CNAME,
count(S.ID) as Total,
((count(S.ID) / (select count(ID) from usr_session_log) )*  100 ) as PERC
FROM `usr_session_log` S
left outer join usr_users U on U.ID = S.user_id
left outer join usr_company C ON C.ID = U.company
group by UNAME, LDATE
Order by PERC DESC

The above works well!

Now i would like to add the latest IP used per user and the lastest date the user accessed the site!

How can i implement this with out sending the whole query haywire?

Thanks
B
 
may be something like:
Code:
select ip, date from table where
date = (select max(date) where user = userid)
and user = userid
with respective changes for your context

------------------------
dev at viewmoresoft.com
tools for your database
 
the above works well? how is that possible, since you are grouping on a column (LDATE) that isn't mentioned anywhere in the query

which table contains the user's IP?

which table contains the date the user accessed the site?



rudy
SQL Consulting
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top