title: How to query Open-high-low-close (OHLC) data from SQL Server
body: <p>I'm trying to retrieve data for a Open-high-low-close (OHLC) chart directly from the database, it's the kind of chart you see of stocks. Is this possible, and if, how? </p>
  
  <p>I have a table like this (simplified):</p>
  
  <p>Date | Price | PriceType</p>
  
  <p>A record is created for each day, I will report per month / year, not per day as used for stocks.</p>
  
  <p>I would like to query something like this:</p>
  
  <p>SELECT PriceType, MAX(Price) as High, MIN(Price) as Low, [Price of first item of month] as Open, [Price of last item of month] as Close GROUP BY PriceType, Year(Date), Month(Date)</p>
  
  <p>To access the SQL Server I use LLBLGen, so an anwser based on that technology would be great, a generic SQL server will do too!</p>
  
  <p>It's SQL 2005, but 2008 is also an option.</p>
  
  <p>Thanks.</p>