Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
masond
Constraint Violating Yak Guru
447 Posts |
Posted - 2013-09-24 : 04:05:25
|
Hey Guys Sorry to bother you so much recently, trying to get my head around some logic Aim – Anything before month_end_date ‘2013-01-01” the data is correct, However anything past this date the data is incorrect. What i want to do is update this querySELECT top 100 [FDMSAccountNo],[Fee_Sequence_Number],[Month_end_date]Into #FactFROM [FDMS].[dbo].[Fact_Fee_History]where [Fee_Sequence_Number] in ('42B','42C')group by FDMSAccountNo,Fee_Sequence_Number,Month_end_datewith this logic select [FDMSAccountNo],CASE WHEN [Fee_Sequence_Number] = '42B' THEN '42C' ELSE [Fee_Sequence_Number] END AS [Fee_Sequence_Number],Month_end_date as Month_end_Date,sum(Retail_amount) as Total,count ([Fee_Sequence_Number]) as CountFeefrom [FDMS].[dbo].[Fact_Fee_History]where [Fee_Sequence_Number] in ('42B','42C')and Month_end_date between '2013-01-01' and '2013-08-01'group by Month_end_date,[FDMSAccountNo],CASE WHEN [Fee_Sequence_Number] = '42B' THEN '42C' ELSE [Fee_Sequence_Number] ENDorder by CountFee desc Looking forward to your help / Solutions |
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
Posted - 2013-09-24 : 06:54:43
|
I'm not getting the your point...Can you explain clearly?--Chandu |
|
|
masond
Constraint Violating Yak Guru
447 Posts |
Posted - 2013-09-24 : 08:17:23
|
HI Bandi Basically anything prior to Month_end_date '2013-01-01' the Fee_Sequence_Number are correct,( you should only have one Fee_Sequence_Number per month_end_date), but after Month_end_date '2013-01-01' there are now two Fee_Sequence_Number per month_end_dateThe last query identifies the where there are two Fee_Sequence_Number per month_end_date, manipulates the data, so that its now correct. SO in a nut shell anything past month_end_date i need to manipulate my first query so that i create one table which is fact |
|
|
|
|
|
|
|