0

Can any one help me for this:

select round(sum(convert(float, size) / 1024 / 1024 / 1024), 2)

There is nothing wrong with the query. The thing here is, I need output as something like 1 GB like that. Is this possible to get the text 'GB' within the column itself.

1
  • 3
    Something like this? select CAST(round(sum(convert(float,size)/1024/1024/1024),2) AS VARCHAR) + ' GB' Commented Mar 16, 2016 at 16:00

1 Answer 1

2
SELECT CAST(round(sum(convert(float,size)/1024/1024/1024),2) AS VARCHAR(20)) + UPPER('gb') AS [Size]

should do the trick...

Sign up to request clarification or add additional context in comments.

5 Comments

How to get them in uppercase. i can't get them. I have tried in many ways
you can force the string to upper case with UPPER(), I have updated my answer to show this. If it still doesn't work, maybe there is something forcing the string to lower-case elsewhere?
Why not write 'GB' instead of upper('gb') ? ;)
@SQLGeorge that's what I had in the original answer, I changed it in the revision to demonstrate the UPPER() function. I appreciate your answer though ;-), because, well, it's en flique...
'en flique' - I will memorize that phrase ;)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.