SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Update Query
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

masond
Constraint Violating Yak Guru

447 Posts

Posted - 09/24/2013 :  04:05:25  Show Profile  Reply with Quote
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 query

SELECT top 100 [FDMSAccountNo],
[Fee_Sequence_Number],
[Month_end_date]
Into #Fact
FROM [FDMS].[dbo].[Fact_Fee_History]
where [Fee_Sequence_Number] in ('42B','42C')
group by FDMSAccountNo,Fee_Sequence_Number,Month_end_date

with 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 CountFee
from [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] END
order by CountFee desc

Looking forward to your help / Solutions

bandi
Flowing Fount of Yak Knowledge

India
2202 Posts

Posted - 09/24/2013 :  06:54:43  Show Profile  Reply with Quote
I'm not getting the your point...

Can you explain clearly?

--
Chandu
Go to Top of Page

masond
Constraint Violating Yak Guru

447 Posts

Posted - 09/24/2013 :  08:17:23  Show Profile  Reply with Quote
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_date

The 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
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000