Message-ID: <33019922.1075841425367.JavaMail.evans@thyme>
Date: Thu, 2 Aug 2001 11:28:26 -0700 (PDT)
From: phillip.platter@enron.com
To: dan.maxwell@enron.com
Subject: SQL2
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-From: Platter, Phillip </O=ENRON/OU=NA/CN=RECIPIENTS/CN=PPLATTE>
X-To: Maxwell, Dan </O=ENRON/OU=NA/CN=RECIPIENTS/CN=Dmaxwell>
X-cc: 
X-bcc: 
X-Folder: \ExMerge - Platter, Phillip\Sent Items
X-Origin: PLATTER-P
X-FileName: phillip platter 6-26-02.PST

Select Lkp.DateValue, Lkp.YearNum, Lkp.MonthNum, Lkp.DayOfWeekName, Beauty.ZoneCode, Beauty.PeakOrOffPeak, Beauty.Price, Beauty.RTOffer, Beauty.Long, Beauty.Short, ISO.Inc, ISO.Dec, (Beauty.Price-ISO.Inc) ISOShort, (ISO.Dec-Beauty.Price) ISOLong
From (Select Lkp.DateValue, Lkp.PeakOrOffPeak, ISO.ZoneCode, avg(ISO.PriceInc) Inc, Avg(ISO.PriceDec) Dec
From LkpCalendar_Definitions Lkp, CA_ISOExPost10Price ISO
Where Lkp.DateTimeValue = ISO.CADateTime
Group By Lkp.DateValue, Lkp.PeakOrOffPeak, ISO.ZoneCode) ISO, (Select DA.CADateTime, DA.ZoneCode, DA.PeakOrOffPeak, DA.Price, RT.RTBid, RT.RTOffer, ((RT.RTBid)-DA.Price) Long, ((DA.Price)-RT.RTOffer) Short
From (Select Lkp.DateValue, Lkp.PeakOrOffPeak, RT.Entity, Avg(RT.Bid) RTBid, Avg(RT.Offer) RTOffer
From CA_HourlyBidOffer RT, LkpCalendar_Definitions Lkp
Where Lkp.DateTimeValue = RT.CADateTime
Group By Lkp.DateValue, Lkp.PeakOrOffPeak, RT.Entity) RT, WEST_SPOTINDEX DA

Where RT.Entity = DA.ZoneCode
AND RT.DateValue = DA.CADateTime
AND RT.PeakOrOffPeak = DA.PeakOrOffPeak) Beauty, LkpCalendar_Definitions Lkp

Where Lkp.DateTimeValue = Beauty.CADateTime
AND Beauty.PeakOrOffPeak = ISO.PeakOrOffPeak
AND Lkp.DateValue = ISO.DateValue
ORDER BY LKP.DATEVALUE