Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

TSQL Challenge 51 - Convert long Binary strings to Decimal strings Expand / Collapse
Author
Message
Posted Monday, March 7, 2011 12:05 AM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Tuesday, December 24, 2013 4:42 AM
Points: 460, Visits: 2,523
Comments posted to this topic are about the item TSQL Challenge 51 - Convert long Binary strings to Decimal strings

.
Post #1073966
Posted Monday, March 7, 2011 8:03 AM
Right there with Babe

Right there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with Babe

Group: General Forum Members
Last Login: Monday, July 14, 2014 8:27 AM
Points: 772, Visits: 240
Not able to reach the site with the link provided the Site. The answer could be

;WITH CTE
AS
(
SELECT SEQ, BINARYVALUE, 0 AS EXPO, CONVERT(NVARCHAR(4000),RIGHT(BINARYVALUE,1)) REMAINING
, CONVERT(NVARCHAR(4000),LEFT(BINARYVALUE,LEN(BINARYVALUE) - 1)) DEDUCTIBLE
FROM TC51

UNION ALL

SELECT SEQ, BINARYVALUE, EXPO + 1, CONVERT(NVARCHAR(4000),RIGHT(DEDUCTIBLE,1))
,CONVERT(NVARCHAR(4000),LEFT(DEDUCTIBLE,LEN(DEDUCTIBLE) - CASE WHEN LEN(DEDUCTIBLE) > 0 THEN 1 ELSE 0 END )) DEDUCTIBLE

FROM CTE
WHERE LEN(DEDUCTIBLE) > 0
)

sELECT SUM(remaining * power(CONVERT(NUMERIC(18,0),2),expo)),seq, binaryvalue
FROM CTE
group by seq, binaryvalue
order by seq, binaryvalue

If there is any better method, please let me know how can I view it?
Post #1074182
Posted Monday, March 7, 2011 8:51 AM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Tuesday, December 24, 2013 4:42 AM
Points: 460, Visits: 2,523
Most people submit their solutions in the first two weeks after the challenge is published. The evaluation then might take another 2-4 weeks to complete. The solutions will be available publicly after the evaluation is completed.

I would encourage you to go to http://beyondrelational.com/puzzles/sqlserver/tsql/51/submit.aspx and submit your solution.


.
Post #1074218
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse