check query (related to prev post)

  • Hello here is my query:

    SELECT DATEADD(hh,DATEDIFF(hh,0,TransactionDate),0) TransactionDate,

    COUNT(TransactionID)as VehiclesCount,

    SUM(ChargedAmount) as ChargedAmount

    FROM Transactions

    where TransactionDate between DATEADD(Hour, -6,getdate())

    and getdate()

    GROUP BY DATEADD(hh,DATEDIFF(hh,0,TransactionDate),0)

    ORDER BYTransactionDate desc

    It returns the data of last 6 hours from the current date time, it shows the data where that hour exists,

    but i want zeros also ,i mean to say if my table has data of hour 12,13,18 not for 14 and 14 then shows zeros rows in my result, plz

    tell me how i do thid as if i used simply without group by then it shows the data rows only which have data for that hour from that 6 hours

    plz help me in this regard and reply me asap.

    Thanx in Advance.

  • No need to start a new thread for this problem. It will just fragment replies and waste people's time.

    Continue here, please

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply