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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Query issue

Author  Topic 

shajimanjeri
Posting Yak Master

179 Posts

Posted - 2010-06-09 : 13:30:00
I have a table with some data. i wrote one query like :


select sum(DISTINCT(round(Month_Bill,0))) as gsmsum,
sum(DISTINCT(round(January,0))) as hardwaresum,
sum(DISTINCT(ROUND(TotalMonthlyFeeAfterDisc + TotalOnetimeFeeAftrDisc + (SlaFee - DiscountAmtSla) ,0))) as datasum
from V_ALLREPORTS WHERE PF = 'PF103050'
OR ( Month(IssuedOn) = '01' and CirciutStatus = 'Applied'
and MONTH(CercuitActivationDate) = '01')

this give me the wrong datasum. Actually for month 01 there is no datasum value

I want if any of the condition is correct then show data

any body can help me

regards
Shaji

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-06-09 : 13:47:41
You haven't provided enough information for us to help you. You say the query gives you the wrong sum, but you don't say what the correct sum is nor what value is wrong. It would be very helpful if you provided sample data that shows the current output and also what you expect it to show.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

shajimanjeri
Posting Yak Master

179 Posts

Posted - 2010-06-09 : 14:04:11
Here after executing this query, it gives me
gsmsum = 1083787
hardwaresum = NULL
datasum = 405331

here datasum should be NULL. There is no data for datasum. But while execute this query I am getting datasum = 405331

Here Month(IssuedOn) = '01' and CirciutStatus = 'Applied' conditions are for sum(DISTINCT(round(Month_Bill,0))) as gsmsum criteria

MONTH(CercuitActivationDate) = '01' condition is for sum(DISTINCT(ROUND(TotalMonthlyFeeAfterDisc + TotalOnetimeFeeAftrDisc + (SlaFee - DiscountAmtSla) ,0))) as datasum

I want to check any of these where conditions.


regards






Go to Top of Page

shajimanjeri
Posting Yak Master

179 Posts

Posted - 2010-06-09 : 14:17:08
Still not clear?
Go to Top of Page

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2010-06-09 : 14:47:28
Have a look at this

How to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx
Go to Top of Page
   

- Advertisement -