SQL Server :: Calculation In Case Don't Work?

Jul 15, 2010

I have below sql statement wich don't work. It don't come up with an error but votepercentage is 0 and when I calculate it manually it should come up with

Dog = 5/9*100 = 55,55
Cat: 4/9*100 = 44,44
in votepercentage

My code:

[Code]....

The result for above code:

Dog 5 0
Cat 4 0

I triple checked that questionAnswersCount is 9 Anyone who can tell me what is wrong with this line:

(CASE WHEN pa.answersCount = 0 THEN 0 ELSE Convert(decimal, ((pa.answersCount/pq.questionAnswersCount) * 100)) END) as votepercentage

View 3 Replies


Similar Messages:

Forms Data Controls :: The Total Amount Show The Correct Calculation Result, But The String Format Dont Work?

Feb 27, 2010

my query is like this " select product_id, product_price, purchase_amout from purcases"

and on my formview i tried to add a "total purchase"

i tried using <asp:Label ID="total_purchase" runat="server" Text='<%# string.format(cint(eval("product_price")*eval("purchase_amout")),"{ Rp 0:###,###,###,###,###}")%>'>

the total amount show the correct calculation result, but the string format dont work.... so it display 20000 instead of Rp 20,000

btw. "Rp" is the currency symbol in my country... i dont use {0:c} coz the server user US currency

View 4 Replies

Setting CustomErrors In Web.config Doesn't Work At This Case?

Dec 20, 2010

In my ASP.NET 3.5 Website which is published in shared hosting provider , I've configured my web.config file like this :

<customErrors mode="On" defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="AccessDenied.htm"/>
<error statusCode="404" redirect="FileNotFound.htm"/>

[code]...

This is a yellow page which is not user friendly and we didn't expect . I'm wondering setting customeError in webconfig doesn't support this type of address or not ? How can i prevent users seeing this yellow page . Edit : solution you mentioned are about configuring IIS ,But as i mentioned earlier , my site has been published on shared hosting provider . I don't have those access at IIS , What should i do at this situation ?

View 3 Replies

Root Path With Tilde - Doesn't Change Upper Case To Lower Case

Dec 30, 2010

I have my project set up with the virtual path "/MyVirtualPath", create the virtual directory in IIS 6 (W2003) and everything works fine. Then to work better with Google Analytics I change the virtual path "/myvirtualpath" and change all redicecciones and links to lowercase. also applies the class "lowercase route urls in aspnet mvc" and works perfectly.

The problem I had to modify the virtual directory in IIS, delete virtual path "/MyVirtualPath" and I created the new "/myvirtualpath", but in all cases I use tilde "~" or where I make a "RedirecToAction" (which should take "LowercaseRoute"), continues to maintain the virtual path "/MyVirtualPath". For example, if I see the HTML source code in the browser, see "/MyVirtualPath/Content/Site.css" instead of "/myvirtualpath/Content/Site.css. "

View 1 Replies

SQL Server :: Date Additions And Calculation Within A Store Procedure?

Oct 12, 2010

is there a function for adding days to a date value within a stored procedure?If I had a field with a start date and a field for duration which would be how many days the even lasts....like if I wanted something like this:TableName.StartDate, DateAdd(TableName.StartDate, TableName.Duration) as EndDate, etc

View 4 Replies

SQL Server :: Change Existing Holiday Calculation Function?

Oct 14, 2010

What changes to the function below are needed to achieve those requirements:- If you pass the same date, then 1 will be returned as the number of days- Return '5' when passing 18.10.2010 to 22.10.2010 (Mo-Fr.)- Return '0.5' when passing same date with (n) hours difference e.g. from 18.10.2010 08:00:00 and 18.10.10 12:00:00 (maybe I should ask start a new threand for this last one)

[Code]....

View 1 Replies

SQL Server :: Inserting Data After Calculation Using Stored Procedure?

Sep 15, 2010

my requirement is like i want to insert data to table after caliculation like table name salaryhike columns salaryinput,20%hike, 25%hike and 30%hike salaryinput column details to be input by the user and hike is to be caliculated and inserted with 20%hike, 25%hike and 30%hike are columns of same table.

View 4 Replies

SQL Server :: Case Statement In Where Clause?

Sep 13, 2010

i trying following query Select

View 4 Replies

SQL Server :: Case Statement Works One Way But Not The Other?

Dec 15, 2010

I have been working on a stored procedure to calculate likert scales for course evaluations. I have the stored procedure done but I ran into an interesting but frustrating situation.

I used a case statement along with a select query to count the number of responses of a given value. Likert scales are usually 5 point scales 5 being the highest and 1 being the lowest. The value that gave me the trouble was null values. In my evaluation page the instert query puts a null value in the field instead of leaving the response blank. These are the two queries I used both are syntactically correct but one works and the other doesn't. #1 Null query that works

[Code]....

Can anyone explain the differences and why one works but the other doesn't? Can it be as simple as switching the WHEN and the column name and if it is would it be advisable the other ones around?

View 4 Replies

SQL Server :: CASE Or Conditional View?

Dec 9, 2010

I have a [Permission] and [Unit] table (permissions types are to view, update, add, ... records). One of the [Unit]'s is "1" for "ALL Units". What I want to do is use either a CASE or IF statement in my view which will pair every [UnitId] (except "1" ofcourse)
if/when the [UnitId] is set to "1".

Here are my view as-is:

[Code]....

Which results in: [Code]....

What I want is: [Code]....

View 3 Replies

SQL Server :: ORDER BY CASE Is Not Working

Jan 19, 2011

I am having trouble with my ORDY By Case Statement. It doesn't seem to be ording correctly. To see it in action, please go to [URL] and click on "latin" and it should change the sort order and when you click back on "common" it should change it back but it doesn't. Here's my code:

[Code]....

View 17 Replies

SQL Server :: Setting Up The CASE Keyword In SQL From Web App?

Mar 7, 2011

I was wondering how I would go about setting up the CASE keyword in SQL from my Web app. I have a table where I need to update anywhere between 20 and 300 rows with different values. My table looks like this

ID EventID SeatType SeatCount Status Comments

On my page, these rows are listed in a table with a textarea to add comments. So when I click a button I need to update All the comments for all the users of a certain "EventID".I think my SQL Statement should go something Like this:

UPDATE Events
SET Comments =
CASE [code]....

Is that correct? I would be getting the ID and comment from each row of the table. Also (using C#) what would be the most efficient way to get this information into the query? I was thinking to use a for statement but I hear many string concatenations requires lots of processing?

[Code]....

View 7 Replies

SQL Server :: Case Statement To Insert New Record Syntax

Aug 5, 2010

I am using a SP to insert into tables base on the parameters but getting syntax errors on:

Msg 156, Level 15, State 1, Procedure Dyno_InsertNewItem, Line 27

View 3 Replies

SQL Server :: How To Use Case Statement In Scalar Valued Function In Sql

Feb 21, 2011

i want to get one value from function using case statement,i tried it but not work

CREATE FUNCTION [FATMS].[fnReturnByPeriod]
(

@Period INT

) [code]....

View 2 Replies

Custom Server Controls :: Case Statement Is Never Executing?

Aug 25, 2010

why the case statement is never running

[Code]....

[Code]....

View 3 Replies

SQL Server :: Using A User Defined Function In A Case Statement?

Sep 23, 2010

I created a function and am trying to access it through a case statement, but I am getting the error:

Cannot find either column "core" or the user-defined function or aggregate "core.f_FiscalYear_Open_Days", or the name is ambiguous.

The case statement is below:

CASE
WHEN c.program_id
= 5
and
CAST(minutes)
As
float)/60
>=
@MiddleSyTargetHrs
/core.f_FiscalYear_Open_Days(c.program_id,Org_Site_ID_Contract,'7-01-2009','7-31-2009')
Then 1
Else 0
End
As
mon_1_hrs

View 4 Replies

Delay In The Development Server Response In Case Of A Postback,in Website?

Jan 18, 2010

I am working on an Asp.net webiste.The response time(in case of a postback) of the pages in the website is ok on my local machine.But when I uploaded the same website to the internal development server and tried to access the server pages from my local machine,its taking bit long(in case of a postback) as compared to my local machine.I do not understand why the same webiste runs slowly on the dev server..

Following is the configuration of dev server.

Microsoft Windows Server 2003 R2 Enterprise Edition service pack 2
Intel(R) Xeon(R) CPU
E5450 @ 3.00GHZ
3.23 GHZ,2.00 GB of RAM
Physical Address extension

Following is the configuration of my local system

Microsoft Windows XP Professional Version 2002 service pack 2
Intel(R) Pentium(R) Dual CPU
E2180 @ 2.00 GHZ
2.00GHZ,1.99 GB of RAM.

View 1 Replies

Localization :: Culture Settings Work On Machine - Don't Work When Moved To Server?

Jan 20, 2010

I am working on a multi-language web site. It is half English and half Portuguese. I have created forms that have portuguese values in it. These forms work perfectly on my desktop. I'm using Cassini as the development server. When I move them over to IIS, they are not loading properly. The text comes up all weird looking. I am declaring the culture in the page attribute: Culture="pt-BR"

View 4 Replies

Show Download Dialog Box In Case Of File Download - Located On Amazon Server

Jan 4, 2010

i am using amazon s3 service. now i want to show download dialog box in my asp.net application when user come on download page. i am using amazon sdk.

View 1 Replies

Forms Data Controls :: Text Validator Case-sensitive / Change The Server-side validator?

Dec 13, 2010

I have a validator on a textbox that validates against a list to ensure that the user doesn't input the same name. When testing it, if I type in the same name including the same case structure, it returns an error. If I change one letter to a different case, it doesn't return an error but rather my SQL server returns a duplicate error. How do I change the server-side validator so that it picks up duplicate names regardless of case?

View 4 Replies

SQL Server :: Using CASE Statement In "IN" Clause Of Query?

Sep 29, 2010

I have a sql datasource with the ControlParameter called ddlDropDownList.

2 questions:

1. Is my syntax below ok, I am getting a runttime error that the syntax is incorrect.

2. I have the select statement set up the control parameter to get the selected value from the dropdownlist as shown below, is that syntax correct? especially the "selectedItem.value" for the propertyname property.

[Code]....

[Code]....

View 6 Replies

Getting "60|error|500|Error Serializing Value Case Of Type Case" When Go To FF And Run It

Feb 14, 2011

I have a custom object that I'm throwing into the viewstate on an async postback. If I step through the code, I can put the object into the viewstate, then call the object from the viewstate and cast it with no problems. The code, when stepped through, has no issues whatsoever. However, when I go to FF and run it, I get "60|error|500|Error serializing value 'Case' of type 'Case.'" First thing that hits me as weird is that the value is being named as the type. It's not like value oCase (an instance of Case) of type Case. I've checked that all containing objects are set for serialization, compiled and rerun the web app.

View 4 Replies

Correct The Method For The Calculation?

Jan 23, 2010

to correct the method for the given below calculation:-

if num1 <=2.500 then

num1.text= (num1) % 10 + Num1

else num1=num1.text= (num1) % 10 + Num1

if num1 >2.500 <=10.00 then

num1.text=(num1) % 10= + Num1

else num1.text= (num1) % 10 + Num1

if num1<=10.000 then

num1.text=(num1) % 2 + Num1

else num1.text= (num1) % 7+ Num1

if num1 <=10.000 then

num1.text= (num1) % 6 + Num1

View 2 Replies

Web Forms :: Printing Calculation To Label?

Nov 19, 2010

I am in the process of building a calorie calculator. I have a calculation ready to test but I am having trouble getting it to print as onto a blank label. Here is what I have so far. I just need to figure out how to print "maintainanswer" back to the user.

View 1 Replies

Web Forms :: NULL Error In Calculation

Jul 28, 2013

In my asp.net+vb web there is a code as under

If dt1.Tables("PresentTotal").Rows(0).Item("C") Is System.DBNull.Value <> True Then
ctxt.Text = dt1.Tables("PresentTotal").Rows(0).Item("C")
Else
ctxt.Text = ""
End If

The script works fine for those peoples number is in that table but when the number of that person is not there in tahat table then it gives error...

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved