|
Corobori
Posting Yak Master
105 Posts |
Posted - 2005-05-30 : 14:56:15
|
| I have got one table tblOperations, containing data on funds (IDTitre) for subscriber (IDSouscripteur) with parts they purchase (NbPartOperation) per date (DateLiberation) and one table tblRetros with amount per funds (Ret_Titre) and period (Ret_Periode).I created a view for summing all parts by share "SELECT IDTitre, SUM(NbPartOperation) AS iTotalNbrParts FROM dbo.tblOperations GROUP BY IDTitre"I create another view summing all part by share and subscriber "SELECT IDTitre, IDSouscripteur, SUM(NbPartOperation) AS iNbrParts FROM dbo.tblOperations GROUP BY IDTitre, IDSouscripteur"I have a problem with those 2 views as I need to join them with the table tblRetros which doesn't contain the datesExample:I can have this:(tblOperations) Date, Funds, Subscriber, Parts10/1/2005, 1, 100, 1015/1/2005, 1, 200, 3020/1/2005, 1, 100, 4026/1/2005, 2, 100, 1016/2/2005, 2, 100, 1015/2/2005, 1, 200, 30(tblRetros) Date, Funds, Amount31/1/2005, 1, 1500031/1/2005, 2, 500020/2/2005, 1, 2000020/2/2005, 2, 7000This would give a vwPartsByFunds where date <= 20/2/2005Funds, Parts1, 31/1/2005, 802, 31/1/2005, 101, 20/2/2005, 1102, 20/2/2005, 20So how can I tweak that view so I can display the tblRetros data where as any date below 31/1 should say display the 31/1 value; any date > 31/1 and <= 20/2 should display the 20/2 value. Thanks !Here is the table's definition:CREATE TABLE [dbo].[tblOperations] ([IDOperation] [int] IDENTITY (1, 1) NOT NULL ,[DateOperation] [datetime] NULL ,[DateLiberation] [datetime] NULL ,[DateApplicationNAV] [datetime] NULL ,[IDEmploye] [int] NULL ,[IDTitre] [int] NULL ,[IDTypeOperation] [smallint] NULL ,[IDSouscripteur] [smallint] NULL ,[IDReference] [smallint] NULL ,[IDDepositaire] [smallint] NULL ,[IDTypeMouvement] [smallint] NULL ,[MontantOperation] [float] NULL ,[CoursOperation] [float] NULL ,[NbPartOperation] [float] NULL ,[IDStatus] [smallint] NULL ,[Comment] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,[Periode] [int] NULL ,[Mail] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]GOCREATE TABLE [dbo].[tblRetros] ([Ret_Titre] [int] NOT NULL ,[Ret_Periode] [datetime] NOT NULL ,[Ret_Montant] [float] NOT NULL ,[Ret_ts] [timestamp] NOT NULL) ON [PRIMARY]GOjean-lucwww.corobori.com |
|