I have a table that stores page images in a web application, keeping
unique_row_id http_session_id page_name page_hit_timestamp ---------------------------------------------------------------- 0 123456789 index.html 2010-01-20 15:00:00 1 123456789 info.html 2010-01-20 15:00:05 2 123456789 faq.html 2010-01-20 15:00:15 3 987654321 index.html 2010-01-20 16:00:00 4 987654321 faq.html 2010-01-20 16:00:05 5 987654321 info.html 2010-01-20 16:00:15 6 111111111 index.html 2010-01-20 16:01:00 7 111111111 faq.html 2010-01-20 16:01:05 8 111111111 info.html 2010-01-20 16:01:15
I want to run a sql query that will show me the most common page where users end browsing.
So my initial thinking is that in my (java) application, I can run a request that selects different http_session_id values ββfrom the table, and then for each individual http_session_id, it will launch another request that will get a page with the last 'page_hit_timestamp and summarize the total for all of these pages. (For the example data above, I would have a score of 2 for info.html and a number of 1 for faq.html.)
But, what I would like to know is: is there a way to combine these two queries into a single sql statement - or do I need to go the way of the stored procedure for this?
I looked at using the connection, but I canβt figure out if it is applicable in this scenario.
PS - I know that I could use similar Google Analytics in my application to provide this information to me, but a) it is a mobile web application that is not very suitable for analytics tools on the shelves, and b) I'm just interested to know whether it can be done in SQL.
Kevin source share