September 18, 2008 at 6:50 am
I am using SQL through an Excel spreadsheet. Problem is, my code is giving me a headache. I have a column that displays the total of completed invites then another that displays the total invites sent. Now there is a third column that would display the % of invites complete, meaning total complete divided by total sent. I am having trouble getting the percentage to show up correctly. Anyone have any ideas on what I can do?
September 18, 2008 at 7:06 am
September 18, 2008 at 7:24 am
case (Select Count(*) from ECSQ1Production..contact where (Nominatedforsurvey='true' and TPAccountID=Contact_InterimDbAccountId and NominatedforSurvey='true' and contactsurveystatus='complete'))
when '0' then '0'
else
(Select convert(numeric(5,2),Count(*)) from ECSQ1Production..contact where (Nominatedforsurvey='true' and TPAccountID=Contact_InterimDbAccountId and NominatedforSurvey='true' and contactsurveystatus='complete'))/(Select convert(numeric(5,2),Count(*)) from ECSQ1Production..contact where (InitialEmailInviteDate is not null and TPAccountID=Contact_InterimDbAccountId and NominatedforSurvey='true'))
end as [% Complete],
September 18, 2008 at 2:37 pm
Problem:
SELECT 1/10
Solution:
SELECT 1/10.0
--Jeff Moden
Change is inevitable... Change for the better is not.
September 19, 2008 at 8:12 am
Jeff Moden (9/18/2008)
Problem:SELECT 1/10
Solution:
SELECT 1/10.0
Many newbies are not beware of implicit convertions 🙂
http://sqlblogcasts.com/blogs/madhivanan/archive/2008/01/16/beware-of-implicit-conversions.aspx
Failing to plan is Planning to fail
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply