|
Posted by Razvan Socol on 11/02/06 11:40
It's a pretty simple query (much easier than doing it in VB):
SELECT MIN(Date) as From, MAX(Date) as To,
Price1, Price2, Price3
FROM TheTable
GROUP BY Price1, Price2, Price3
Razvan
edouard.spooner@gmail.com wrote:
> Hi,
>
> I have a tricky SQL query problem that I'm having probs with.
>
> I have a table which resembles something like this
>
> Date | Price1 | Price2 | Price3
> 01 Jan 2006 | 100 | 100 | 100
> 02 Jan 2006 | 100 | 100 | 100
> 03 Jan 2006 | 100 | 100 | 100
> 04 Jan 2006 | 115 | 100 | 100
> 05 Jan 2006 | 115 | 100 | 100
> 06 Jan 2006 | 115 | 115 | 115
> 07 Jan 2006 | 115 | 100 | 100
> 08 Jan 2006 | 100 | 100 | 100
> 09 Jan 2006 | 100 | 100 | 100
>
> and I want to write a query/view that will return this
>
> >From | To | Price1 | Price2 | Price3
> 01 Jan 2006 | 03 Jan 2006 | 100 | 100 | 100
> 04 Jan 2006 | 05 Jan 2006 | 115 | 100 | 100
> 06 Jan 2006 | 06 Jan 2006 | 115 | 115 | 115
> 07 Jan 2006 | 07 Jan 2006 | 115 | 100 | 100
> 08 Jan 2006 | 09 Jan 2006 | 100 | 100 | 100
>
> Any ideas?
>
> I know how to write a routine that would do the same in VB but I am
> looking to do a lot of the same calculation/query so I need it to be
> fast (which VB wouldnt be)
>
> TIA
>
> Eddie
Navigation:
[Reply to this message]
|