Forum Replies Created

Viewing 15 posts - 511 through 525 (of 1,398 total)

  • Reply To: Replace Numbers

    A numbers splitter is a really nice solution.  I thought the question was already answered.  What else could be done with a numbers splitter?

  • Reply To: Replace Numbers

    Why not get rid of FLOAT as soon as possible by CAST'ing POWER to BIGINT ?

    select NumericValue, conv_bigint.num
    from #IntChange ic
    cross apply (select...
  • Reply To: OK, I still think like a programmer -- is there a better way to do this?

    Here's an attempt to refactor the query with functional equivalency (afaik)

    insert into [Micros].[UserTerminations]([UserID], [TerminationDateTime])
    select u.[HostUserId], getdate()
    from [Micros].[Users] AS u
    where exists (select 1
    ...
  • Reply To: Conditional Trailing Totals

    Ok when you explode the lines the Demand is being split up to correspond incrementally to the date.  However, when expanded the OnHand and NextJobQty are being replicated in full. ...

  • 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...

  • 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?

Viewing 15 posts - 511 through 525 (of 1,398 total)