Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Howdy,

 

The database I am working with has a table of transactions (called MunitTransaction) and I wish to retrieve the total number of transactions, and their total monetary value, between two dates. However, I want them grouped into groups.

 

For example, in the following query, I want to retrieve information about today's transactions, with the transactions grouped into hourly chunks:

 

SELECT
   COUNT( [MunitID] ) AS [TransCount],
   SUM( [Value] ) AS [Revenue],
   (DATEDIFF(hh, '2006-07-14 00:00:00', [DateCreated])) AS [interval]
FROM
   [MunitTransaction]
WHERE
   (   [MunitTransaction].[DateCreated]
       BETWEEN
       '2006-07-14 00:00:00'
       AND
       '2006-07-15 00:00:00' )
GROUP BY
   [interval]
ORDER BY
   [interval]

 

The error I am getting is Invalid column name 'Interval'. I have tried a few things but they make no difference, or produce other errors. If anybody has an idea of how to do this, I would appreciate it if you could post back.

 

Thanks peeps. :cool:

Never trouble another for what you can do for yourself.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...