473,385 Members | 1,325 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

SQL Query Question

MX1
Here's a type of query I'm always having trouble with. There are 4 fields
in a web access log table.

User | Date | Time | Destination

I want to show all the instances of a user hitting a particular web site,
but I only want a single entry to represent that visit (not the 10 or 15
that represent every graphic that was obtained from the page as is typical
with imported web logs).

Here is a sample entry:

JackX 10/31/03 2:24:03 PM www.website.com/default.asp
JackX 10/31/03 2:24:03 PM www.website.com/images/image1.gif
JackX 10/31/03 2:24:03 PM www.website.com/images/image2.gif
JackX 10/31/03 2:27:05 PM www.website.com/default.asp
JackX 10/31/03 2:27:05 PM www.website.com/image1.gif

In my query, I'd like it to only pull the first and fifth record.
Essentially, pulling all sites with "*website.com*" and the computer name
"JackX" but I want it to only pull one entry from the 2:24:03 block and one
entry from the 2:27:05 block. How can I fitler a distinct row from the
time? Any help would be great! :)
Nov 12 '05 #1
3 2805
If it's just the *.gif files that are causing the trouble, filter them out
by only including *.asp (or *.htm) files:
SELECT User, Date, Time, Destination
FROM MyTable
WHERE Right(Destination, 4) = ".asp" OR Right(Destination, 4) = ".htm"
P
"MX1" <mx*@mx1.abc> wrote in message
news:Bg7rb.106710$ao4.321619@attbi_s51...
Here's a type of query I'm always having trouble with. There are 4 fields
in a web access log table.

User | Date | Time | Destination

I want to show all the instances of a user hitting a particular web site,
but I only want a single entry to represent that visit (not the 10 or 15
that represent every graphic that was obtained from the page as is typical
with imported web logs).

Here is a sample entry:

JackX 10/31/03 2:24:03 PM www.website.com/default.asp
JackX 10/31/03 2:24:03 PM www.website.com/images/image1.gif
JackX 10/31/03 2:24:03 PM www.website.com/images/image2.gif
JackX 10/31/03 2:27:05 PM www.website.com/default.asp
JackX 10/31/03 2:27:05 PM www.website.com/image1.gif

In my query, I'd like it to only pull the first and fifth record.
Essentially, pulling all sites with "*website.com*" and the computer name
"JackX" but I want it to only pull one entry from the 2:24:03 block and one entry from the 2:27:05 block. How can I fitler a distinct row from the
time? Any help would be great! :)

Nov 12 '05 #2
SELECT WebHits.User, WebHits.Time, First(WebHits.Date),
First(WebHits.Destination)
FROM WebHits
GROUP BY WebHits.User, WebHits.Time;

Assuming that you're not actually bothered which 'hit' you record. You don't
mention the date. You'd probably want to group on that too, although it is
fairly unlikely that someone would hit a particular web site at the same
time, to the second, on different days.

Yours, Mike MacSween

"MX1" <mx*@mx1.abc> wrote in message
news:Bg7rb.106710$ao4.321619@attbi_s51...
Here's a type of query I'm always having trouble with. There are 4 fields
in a web access log table.

User | Date | Time | Destination

I want to show all the instances of a user hitting a particular web site,
but I only want a single entry to represent that visit (not the 10 or 15
that represent every graphic that was obtained from the page as is typical
with imported web logs).

Here is a sample entry:

JackX 10/31/03 2:24:03 PM www.website.com/default.asp
JackX 10/31/03 2:24:03 PM www.website.com/images/image1.gif
JackX 10/31/03 2:24:03 PM www.website.com/images/image2.gif
JackX 10/31/03 2:27:05 PM www.website.com/default.asp
JackX 10/31/03 2:27:05 PM www.website.com/image1.gif

In my query, I'd like it to only pull the first and fifth record.
Essentially, pulling all sites with "*website.com*" and the computer name
"JackX" but I want it to only pull one entry from the 2:24:03 block and one entry from the 2:27:05 block. How can I fitler a distinct row from the
time? Any help would be great! :)

Nov 12 '05 #3
MX1 wrote:
Here's a type of query I'm always having trouble with. There are 4 fields
in a web access log table.

User | Date | Time | Destination

I want to show all the instances of a user hitting a particular web site,
but I only want a single entry to represent that visit (not the 10 or 15
that represent every graphic that was obtained from the page as is typical
with imported web logs).

Here is a sample entry:

JackX 10/31/03 2:24:03 PM www.website.com/default.asp
JackX 10/31/03 2:24:03 PM www.website.com/images/image1.gif
JackX 10/31/03 2:24:03 PM www.website.com/images/image2.gif
JackX 10/31/03 2:27:05 PM www.website.com/default.asp
JackX 10/31/03 2:27:05 PM www.website.com/image1.gif

In my query, I'd like it to only pull the first and fifth record.
Essentially, pulling all sites with "*website.com*" and the computer name
"JackX" but I want it to only pull one entry from the 2:24:03 block and one
entry from the 2:27:05 block. How can I fitler a distinct row from the
time? Any help would be great! :)

Create a new field in your query to use just the hours and minutes from the 3rd field
and the Date:

AccessTime: Format([Date], "yyyymmdd")) & Format([Time, "hhnn")

and Group on it. This will group by the minute. It's not a perfect solution as the
loading of a page could overlap a minute boundary. You could also add the Left()
portion of the Destination field to limit to a particular site (host).

Left([Destination], InStr([Destination], "/") - 1)

--
'-------------------------------
' John Mishefske
'-------------------------------

Nov 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: majsen | last post by:
Hi, I have problem running this query. It will time out for me... My database are small just about 200 members. I have a site for swaping appartments (rental). my query should look for match in...
8
by: Együd Csaba | last post by:
Hi All, how can I improve the query performance in the following situation: I have a big (4.5+ million rows) table. One query takes approx. 9 sec to finish resulting ~10000 rows. But if I run...
3
by: John Ortt | last post by:
> I have a table of dates in ascending order but with varying intervals. I > would like to create a query to pull out the date (in field 1) and then pull > the date from the subsequent record...
3
by: Ekqvist Marko | last post by:
Hi, I have one Access database table including questions and answers. Now I need to give answer id automatically to questionID column. But I don't know how it is best (fastest) to do? table...
7
by: serge | last post by:
How can I run a single SP by asking multiple sales question either by using the logical operator AND for all the questions; or using the logical operator OR for all the questions. So it's always...
6
by: jjturon | last post by:
Can anyone help me?? I am trying to pass a Select Query variable to a table using Dlookup and return the value to same select query but to another field. Ex. SalesManID ...
2
by: mmitchell_houston | last post by:
I'm working on a .NET project and I need a single query to return a result set from three related tables in Access 2003, and I'm having trouble getting the results I want. The details: ...
22
by: Stan | last post by:
I am working with Access 2003 on a computer running XP. I am new at using Access. I have a Db with a date field stored as mm/dd/yyyy. I need a Query that will prompt for the month, ie. 6 for...
3
by: Richard Hollenbeck | last post by:
I am very sorry about the (almost) re-post, but you will see that my first question wasn't very clear; I have another question I posted this morning called, "in DAO: Run time error 3061 Too few...
16
by: ARC | last post by:
Hello all, So I'm knee deep in this import utility program, and am coming up with all sorts of "gotcha's!". 1st off. On a "Find Duplicates Query", does anyone have a good solution for...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.