Home  |  Forums  |  914 Info  |  Blogs
 
914World.com - The fastest growing online 914 community!
 
Porsche, and the Porsche crest are registered trademarks of Dr. Ing. h.c. F. Porsche AG. This site is not affiliated with Porsche in any way.
Its only purpose is to provide an online forum for car enthusiasts. All other trademarks are property of their respective owners.
 

Welcome Guest ( Log In | Register )

2 Pages V < 1 2  
Reply to this topicStart new topic
> WOT: SQL query help needed again ...
ClayPerrine
post Mar 26 2007, 09:46 PM
Post #21


Life's been good to me so far.....
***************

Group: Admin
Posts: 15,514
Joined: 11-September 03
From: Hurst, TX.
Member No.: 1,143
Region Association: NineFourteenerVille



QUOTE(SirAndy @ Mar 26 2007, 10:00 PM) *

QUOTE(ClayPerrine @ Mar 26 2007, 06:47 PM) *

Andy,
Look up a tool on Microsoft's website called "eventcombMT". It will parse the event logs on any server, and return them by date, type and user, or any other field. It also doesn't require a table be imported to SQL, just query them live. Embed the app in a stored procedure, and feed it the proper switches.


this is *NOT* a windows event log !!!

it's just a DB table called tbl_EventLog and has absolutely NOTHING to do with the OS eventlog!

it logs events of peoples (users) interaction with the B2B website ...
(IMG:style_emoticons/default/bye1.gif) Andy

PS: it's *NOT* a webserver log either! this is a completely proprietary format used by the B2B website to track specific events on the user pages.
it's populated by the ASP code and i need to build a page in the admin section that allows to break down the log by user/date ...



OK...OK... I am suitably chastised... I thought you were pulling in the windows event log and then searching it with a SQL query.

User is offlineProfile CardPM
Go to the top of the page
+Quote Post
bigkensteele
post Mar 26 2007, 10:18 PM
Post #22


Major Member
****

Group: Members
Posts: 2,197
Joined: 30-August 04
From: Cincinnati, OH
Member No.: 2,660
Region Association: South East States



I have kicked this around for a half hour, and I think that the most efficient way to do it would be a to create a work table using something like this:

SELECT xxx.user, xxx.date, Max(xxx.time) AS MaxTime INTO WORKTABLE
FROM xxx
GROUP BY xxx.user, xxx.date
HAVING xxx.date = 03/26/2007;

Then do a join of table xxx and WORKTABLE using user, date, and time = MaxTime.

SELECT xxx.*
FROM WORKTABLE INNER JOIN xxx ON (WORKTABLE.user = xxx.user)
and (WORKTABLE.date = xxx.date)
and (WORKTABLE.MaxTime = xxx.time);

With the above solution, I would create an additional index on your table over the user, date and time columns.

However, if your primary key is a sequentially assigned numeric, you could include that in the first query as

SELECT Last(xxx.key) AS LastKey, xxx.user, xxx.date, Max(xxx.time) AS MaxTime INTO WORKTABLE
FROM xxx
GROUP BY xxx.user, xxx.date
HAVING xxx.date = 03/26/2007;

and then your second query would only need to be

SELECT xxx.*
FROM WORKTABLE INNER JOIN xxx
ON (WORKTABLE.LastKey = xxx.key);

Hope this helps, please let us know what you end up doing.
BKS
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
drewvw
post Mar 26 2007, 10:23 PM
Post #23


new england car guy
***

Group: Members
Posts: 1,631
Joined: 24-February 06
From: Boston, MA
Member No.: 5,630
Region Association: North East States



good response...avoiding IN clauses is nice because they are pretty expensive.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
SirAndy
post Mar 26 2007, 10:29 PM
Post #24


Resident German
*************************

Group: Admin
Posts: 41,675
Joined: 21-January 03
From: Oakland, Kalifornia
Member No.: 179
Region Association: Northern California



QUOTE(bigkensteele @ Mar 26 2007, 08:18 PM) *

I have kicked this around for a half hour, and I think that the most efficient way to do it would be a to create a work table using something like this:


hmmm, i thought about using a temp table as well. that might work ... (IMG:style_emoticons/default/idea.gif)

too bad Microsoft never got over the fact that "DISTINCT ON" is not part of the SQL standard.
"DISTINCT ON" let's you specify multiple columns to return but the distinct clause is only used on the column you specify with the ON param ...

really too bad MS does not support it. but many others don't either. would have been nice to have, as it would solve my problem and let me get away with just one simple query ...

for now, i'm doing to two nested queries in the code. it works fine and speed is not an issue here as it is in the admin section of the B2B site.
the page only gets maybe 30 hits a day ...

thanks for all the input guys!
(IMG:style_emoticons/default/pray.gif) Andy
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

2 Pages V < 1 2
Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 7th June 2024 - 08:22 AM