Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

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

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],
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

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

Flowing Fount of Yak Knowledge

2242 Posts

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

Can you explain clearly?

Go to Top of Page

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  
 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.02 seconds. Powered By: Snitz Forums 2000