Refine my t-sql query to increase performance : Created a sql query to summarize some data.
It is slow, so I thought I'd ask for some help.
Table is a log table that has :  loc,tag,entrytime,exittime,visits,entrywt,exitwt.
My test log has 700,000 records in it.  The entrytime and exittime are epoch values.
I know my query is inefficient as it rips through the table 4 times.

        select loc,edate,tag,
    (Select COUNT(*)  from mylog as ml where  mvlog.loc = ml.loc and mvlog.edate = CONVERT(date, DATEADD(ss, ml.entrytime,'19700101')) and mvlog.tag = ml.tag) as visits,
    (Select SUM(entrywt - exitwt) from mylog as ml2 where  mvlog.loc = ml2.loc and mvlog.edate = CONVERT(date, DATEADD(ss, ml2.entrytime,'19700101')) and mvlog.tag = ml2.tag) as consumed,
    (Select SUM(exittime - entrytime) from mylog as ml3 where  mvlog.loc = ml3.loc and mvlog.edate = CONVERT(date, DATEADD(ss, ml3.entrytime,'19700101')) and mvlog.tag = ml3.tag) as occupancy
    from eventlogV as mvlog with (INDEX(pt_index))

index pt_index is fields tag and loc.

When I run this query, it completes in roughly 30 seconds.   Since my query is inefficient, I am sure it can be better.

any ideas appreciated.