473,499 Members | 1,893 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to display a numeric value in different formats depending on value

1 New Member
I need to be able to display data in a different decimal format depending on the value of a selected column ("myDecimalData"). Below does not work, every value is displayed in hundredths, and I do not understand why. How would I accomplish this?

For instance, my data:
less than 10 --> sample: I want to display 9.00 as 9.00
between 10 and 1000 --> sample: I want to display 10.11as 10.1
greater than 1000 --> sample: I want to display 1000.11 as 1000


Expand|Select|Wrap|Line Numbers
  1. SELECT
  2. CASE 
  3. WHEN myDecimalData > 1000 THEN CONVERT(int, myDecimalData)
  4. WHEN myDecimalData < 10 THEN CONVERT(DECIMAL(18, 2), myDecimalData)
  5. WHEN myDecimalData between 10 and 1000 THEN CONVERT(DECIMAL(18, 1), myDecimalData)
  6. END as NewDecimalData from myTable
  7.  
Dec 27 '10 #1
1 1222
ck9663
2,878 Recognized Expert Specialist
This would be much better handled in your front-end, not in back-end...

Good Luck!!!

~~ CK
Dec 27 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
3224
by: Sorisio, Chris | last post by:
Ladies and gentlemen, I've imported some data from a MySQL database into a Python dictionary. I'm attempting to tidy up the date fields, but I'm receiving a 'mx.DateTime.Error: cannot convert...
6
15557
by: Kevin Frey | last post by:
Hello, I have a table which contains some nullable columns. I want to write a single query, which can be prepared (ie. prepared statement), that can handle null or non-null values for the where...
7
1147
by: nebjy | last post by:
Hi, I've got a problem where I want to have an interface to a Graphics class (though the nature of the class isn't relevant to the problem), and I want to have a method that returns a pointer to a...
1
6684
by: Martin | last post by:
Dear Group Sorry for bothering you again but I need expert advice on this. I have placed a HTML textbox on my aspx form and converted it to run as a server control. At some point in my code I...
2
1632
by: Kiran | last post by:
Hi, Is it possible to display date in different languages depending upon the culture. Thanks Kiran
6
5618
by: Aussie Rules | last post by:
Hi, I have a datepicker that show a calender. The user picks a date and the time component is always 00:00. I then have a drop down that provides a list of times, (10:00, 11:00 etc), and I...
4
2448
by: Matt Kruse | last post by:
According to standards, if an option is selected and it has no VALUE attribute, the contents of the option tag is to be submitted. So: <select name="sel"> <option selected>Value</option>...
3
2622
by: solargovind | last post by:
Hi, How to get another Control value as a Default value of other control? For example, Whatever the value entered in Text1, need to come in Text 2 also. If require, the user can change the...
7
2539
by: olseni | last post by:
Hi all I hope someone can help me with this. I am sure there is a solution, but I cannot seem to find it.... I need to make a report with the following format: In the columns I have 5 samples,...
1
1746
by: kashib | last post by:
What I am looking for is a C# example that can send multiple documents of different formats (eg pdf, doc, docx, jpeg etc)to the printer as one print job, I am not sure of the best approach. Can you...
0
7131
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7007
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7174
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7388
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4919
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3091
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1427
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
665
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
297
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.