Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
TazMania
Yak Posting Veteran
63 Posts |
Posted - 2004-08-13 : 03:36:15
|
| Hi :)I've made the closed company website, where we log the user activity for which file they download, and when etc.But my problem is that the log tabel, are in time gettin' pretty huge quick, so I thought that I of course, could use group by.. but unfortunately it isn't working.This is how far i am..SELECT logID,fileID,fileDate,fileName,fileHash,fileHits,fileLatestHitdate,userID,userIP FROM FILESLOG Group BY logID,fileID,fileDate,fileName,fileHash,fileHits,fileLatestHitdate,userID,userIPThe above query should only show 2 result, but are instead showing 4.if I remove logid and filelatesthitdate, it works fine.but unfortunately i need those two in the query.isn't there a way of do something like this ?SELECT logID,fileID,fileDate,fileName,fileHash,fileHits,fileLatestHitdate,userID,userIP FROM FILESLOG Group BY fileNameAny help would be very much appreciated !Best regardsTaz |
|
|
Lumbago
Norsk Yak Master
3271 Posts |
Posted - 2004-08-13 : 03:48:16
|
| To make GROUP BY useful you need some sort of aggregate function on the selected fields, like SUM(), AVG(), MAX(), ... in your case here the group by is identical to the select which doesn't really make any sense.--Lumbago"Real programmers don't document, if it was hard to write it should be hard to understand" |
 |
|
|
Andraax
Aged Yak Warrior
790 Posts |
Posted - 2004-08-13 : 03:55:55
|
| Hi!As Lumbago says, use an aggregate function on the fields you want to limit. Or limit your result either horisontally or vertically, by using a "where"-clause (for example limit the time span of your query) or by limiting the columns and using group by which will be the same as using the DISTINCT keyword./Andraax |
 |
|
|
|
|
|
|
|