Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 select 3 digit and next to decima

Author  Topic 

gangadhara.ms
Aged Yak Warrior

549 Posts

Posted - 2010-02-11 : 05:11:19
Dear All,

I need to write a select query in this format.

If my input parameter is 44344 i need to select 443.4
553535 --> 553.5
867621 -->867.6
etc

How to write a select query for this.

Please help me
Thanks,
Gangadhar

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-02-11 : 05:21:09
[code]SELECT LEFT(STUFF(yourcol,4,0,'.'),5) FROM Table[/code]

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

gangadhara.ms
Aged Yak Warrior

549 Posts

Posted - 2010-02-11 : 05:44:14
Hi Visakh,
Thanks for your immediate reply

If the input is only 85 then i will get NULL i want the same if the count is lessthan 3.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-02-11 : 05:47:26
so for 85 what should be your output?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-02-11 : 05:52:07
quote:
Originally posted by gangadhara.ms

Hi Visakh,
Thanks for your immediate reply

If the input is only 85 then i will get NULL i want the same if the count is lessthan 3.



Why do you want to do this?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

gangadhara.ms
Aged Yak Warrior

549 Posts

Posted - 2010-02-11 : 06:18:50
For 85 the output should be 85 itself
I mean any value count lessthan 3 should be same as it is .
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-02-11 : 06:22:23
SELECT LEFT(COALESCE(STUFF(yourcol,4,0,'.'),yourcol),5) FROM Table

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -