?
Solved

Generate histogram using SQL query based on timeseries data

Posted on 2004-09-08
3
Medium Priority
?
428 Views
Last Modified: 2008-03-17
I would like to generate a histogram based on a set of time series data stored in SQL server.  For example I have lots of rows of data stamped with a date and time and want to create 24 classes to put the data in.  Is there a way that I can do this with a SQL query rather than writing an external program?  The BOL has a topic listed under "histogram chart" but I don't think that applies to what I am talking about.
0
Comment
Question by:stealth188
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 17

Assisted Solution

by:BillAn1
BillAn1 earned 200 total points
ID: 12011466
You can do it with a case statement,

e.g.
     SELECT bucket, count(*) from (
               SELECT
                   case when DateStamp < '2001-01-01' then 'bucket1'
                           when DateStamp between '2001-01-01' and '2002-01-01' then 'bucket2'
                           when DateStamp between '2002-01-01' and '2003-01-01' then 'bucket3'
                           ...
                  end as bucket
                FROM MyTable ) inr
              group by bucket

0
 
LVL 12

Accepted Solution

by:
kselvia earned 800 total points
ID: 12012221
Perhaps see this posting for a similar question and solution:

http://www.experts-exchange.com/Databases/Microsoft_SQL_Server/Q_20999291.html
0
 
LVL 1

Author Comment

by:stealth188
ID: 12017300
Thank you both for your input.  I'll be working with this today and let you know how it works out.  Thanks!
0

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Suggested Courses

741 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question