|
I have a table called tbloffence where we can see list of offence which workers have done in worksite.so now i want to display the sumtotal of their offence in .aspx page based on workes userid,but the condition is like this:
a) offence since last login:
b)offence in last 1 month.
i want to write a sql query based on this condition...how can i track"offence since last login"in sql server 2005
|
|
|
|
|
This is not an specific question. To get better answer, I would suggest you to generalize the question and provide more information.
Anyway
This is a very simple problem if I did understand properly.
All you need is to record log in time. that is everytime user log in the user.
And you would have to work in two different Query or may be in Procedeure, where you would send the user_id and procedure will return the result.
|
|
|
|
|
Actually i want to workin 3 tables
1)tbloffence : where we will get the sum(offence) here i track maincontractorID and sum(offence) query will be like this :
"SELECT sum(o.OffenceID) as OffenceNumber,u.UserID
from tblOffence o
inner join tblSubContractor ts on
o.MainContractorID=ts.SubContractorID"
from here i will chk the tblUSER with these subcontractorID :
"inner join tblUser u on
u.SubContractorID=ts.SubContractorID" .
and my doubt is that upto here i will get the total sum of offence and appropriate userid.,for eg
UserID : 520 TotalOffence:6000
but there is another table called tblAuditTrailSession where we will get logondate and userid which is tracking here..so i want to display offence based on userlogin(userid) ..since last login. i want a help in query format..Hope this is a generalized format question.
modified 19-Apr-12 4:26am.
|
|
|
|