+ Reply to Thread
Results 1 to 5 of 5

Thread: decimal values for equation in a sql query

  1. #1
    Registered User
    Join Date
    12-07-2010
    Location
    south africa
    MS-Off Ver
    Excel 2010
    Posts
    29

    decimal values for equation in a sql query

    SELECT T_vineyardblockdata.cultivars AS cultivars, Count(T_vineyardblockdata.cultivars) AS Total, Q_countTotalsvineyardblock.countblocks AS summation, [Total]*100\[summation] AS Percentage
    FROM T_vineyardblockdata, Q_countTotalsvineyardblock
    GROUP BY T_vineyardblockdata.cultivars, Q_countTotalsvineyardblock.countblocks;
    i have this query. i have tried to set the formats in design view but cannot get the PERCENTAGE column to display decimal values...

    Example: Total = 10; summation = 3 then Percentage = 3.33 but with my sql this Percentage = 3

    any ideas?
    Last edited by st0kvis; 09-22-2011 at 03:48 AM. Reason: problem solved

  2. #2
    Forum Guru davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2007
    Posts
    1,879

    Re: decimal values for equation in a sql query

    You could use Access's Format function:
    SELECT T_vineyardblockdata.cultivars AS cultivars, Count(T_vineyardblockdata.cultivars) AS Total, Q_countTotalsvineyardblock.countblocks AS summation, Format([Total]*100\[summation],"0.00") AS Percentage
    FROM T_vineyardblockdata, Q_countTotalsvineyardblock
    GROUP BY T_vineyardblockdata.cultivars, Q_countTotalsvineyardblock.countblocks;
    Is your code running too slowly?
    Does your workbook or database have a bunch of duplicate pieces of data?
    Have a look at this article to learn the best ways to set up your projects.
    It will save both time and effort in the long run!


    Dave

  3. #3
    Registered User
    Join Date
    12-07-2010
    Location
    south africa
    MS-Off Ver
    Excel 2010
    Posts
    29

    Re: decimal values for equation in a sql query

    Hey dave, thanks for your response, now i get 3.00 instead of 3.33

  4. #4
    Forum Guru davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2007
    Posts
    1,879

    Re: decimal values for equation in a sql query

    Given your formula, I'd expect 333.33. I don't know why this just occured to me, but instead of using "0.00" you could just use "Percentage", I think.

    Where are you reviewing your results? If in a table, check that the data type is double instead of integer.
    Is your code running too slowly?
    Does your workbook or database have a bunch of duplicate pieces of data?
    Have a look at this article to learn the best ways to set up your projects.
    It will save both time and effort in the long run!


    Dave

  5. #5
    Registered User
    Join Date
    12-07-2010
    Location
    south africa
    MS-Off Ver
    Excel 2010
    Posts
    29

    Re: decimal values for equation in a sql query

    got it the \(modulus) should be a /(division) ! i have hit a new level of noobness!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.2.0