Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL Select statement
Message
 
 
À
17/04/2008 14:31:15
Jerry Tovar
Dana Corporation Dana It
Maumee, Ohio, États-Unis
Information générale
Forum:
ASP.NET
Catégorie:
Bases de données
Divers
Thread ID:
01311547
Message ID:
01311752
Vues:
16
>I am trying to define a query in my DataSet that takes the SUM of a field and multiple it by a number.
>
>In example 1 below, I receive an error when trying to preview the data. However, example 2 works fine, but I want to be able to pass in the percent and not have it hard coded.
>
>How can I make example 1 work?
>
>
>//Example 1.
>//Does not work.
>//Error: Syntax error converting the varchar value '.247' to a column of data type int.
>SELECT <fields>,
>   SUM(Forecast.total) * @lnpercent AS ytd
>
>//Example 2.
>//Works.
>SELECT <fields>,
>   SUM(Forecast.total) * .247 AS ytd
>
>
>
>Thanks,
>
>Jerry

Did you try to add CAST function around the SUM ?
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform