Forum Replies Created

Viewing 15 posts - 406 through 420 (of 1,295 total)

  • Reply To: Calculate number of times a number can be split evenly into pre-defined groups

    It's algebra which could be directly calculated, no?

    1555201/2^x=800

    2^x=1555201/800

    log10(2^x)=log10(1555201/800)

    x = log10(1555201/800) / log10(2)

    x=10.92481343

    The number of times it would need to be "applied" before it crossed the 800 barrier would be the...

    • This reply was modified 2 years, 5 months ago by  Steve Collins.
  • Reply To: Conditional Trailing Totals

    ross.hughes wrote:

    I am working on a job shortage report that first consumes inventory and then works through job supply one job at a time.  The query is using sum over...

  • Reply To: Replace Numbers

    What about those flying cars?  Your code converts the 'NumericValue' column into VARCHAR(10) which is only ok as long as the integer is positive.  My code converted to VARCHAR(20) because...

  • Reply To: Replace Numbers

    ScottPletcher wrote:

    What about a potential negative sign?  You gonna add a phony replacement in for that too?

    Good idea!  Yes, I added ('-', '-') and it works with negative integers now...

  • Reply To: Replace Numbers

    To review, the table definition provided by the OP

    CREATE TABLE dbo.IntChange (NumericValue INT)

    INSERT INTO dbo.IntChange
    VALUES (15697)
    ,(876)
    ,(1452)
    ,(3374)
    ,(894)
    ,(84516)

    You have some reason to believe the future universe of possible inputs...

  • Reply To: Replace Numbers

    Wow all that.  Ok maybe something like this

    select IcC.NumericValue,
    stuff((select ''+v.repl
    ...
  • Reply To: Replace Numbers

    You feel misled?  It's an axiomatic statement of equivalency

  • Reply To: Replace Numbers

    ScottPletcher wrote:

    Your code also has zeros just disappear completely from your results.  It's never explicitly stated that zeros can't appear in these numbers.  Just in case they do, I think...

  • Reply To: Replace Numbers

    ScottPletcher wrote:

    Is that code fundamentally different than the first query I posted using the same method?

    No temp table

    No Cartesian product without row goal, i.e. SELECT TOP(n)

    No LEFT JOIN

    No ISNULL

     

  • Reply To: How to redesign a query

    Sorry it's not clear to me.  Maybe a more detailed example could help

  • Reply To: How to redesign a query

    What are the expected Usage and Result values for each row of the @t table?

  • Reply To: Replace Numbers

    Steve Collins wrote:

    maybe something like this

    select ic.NumericValue, 
    stuff((select '' + v.repl
    ...

    • This reply was modified 2 years, 6 months ago by  Steve Collins.
  • Reply To: Replace Numbers

    The REPLACE method maybe is not appropriate here but I still would like to know how that works.  Anyway, given this is version 2016 maybe something like this

                

    October 23, 2021 at 4:29 pm

    #3943618

  • Reply To: Replace Numbers

    Hold a sec, the code above is making multiple replacements of the same character.  7 replaces 1 then 5 replaces 7.  The reason seems to be because the order of...

    • This reply was modified 2 years, 6 months ago by  Steve Collins.
  • Reply To: Replace Numbers

    This is one of those gray areas... or idk maybe someone can explain why this actually works.  For reasons unknown, afaik when the REPLACE function is used in the righthand...

Viewing 15 posts - 406 through 420 (of 1,295 total)