Forum Replies Created

Viewing 15 posts - 46 through 60 (of 1,419 total)

  • Reply To: Replace calculation in cursor with set based logic

    Why are you using these data types with this numerical precision?  By making @Factor DECIMAL (9,7) and applying this percentage to a price it adds significance to decimal places to...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: Count of Distinct Values

    One way to unpivot unique values (of columns [Emp_1], [emp_2], [Emp_3]) could be to CROSS APPLY their UNOIN. The syntax might appear to be unusual because the subquery doesn't contain...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: Query Help to show record in single row

    with stub_cte as (
    select BName, StartDate, StartTime,
    lag(StartDate) over (partition by v.stub...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: Final SELECT with WHERE based on passing in variable from Dropdown box

    The @dateChoice variable is passed in from a dropdown box and the WHERE clauses between the two queries are different.  Syntax-wise you could try IF @dateChoice = 'DOS' SELECT ... ...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: Help with parent/child query please

    The only relational operator which seems required is a partial CROSS JOIN of #tmp (WHERE 'parent_id' IS NULL) to #tmp (WHERE 'parent_id' IS NOT NULL) ON 'uniqueid'.  Then it's a...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: Read data from json file

    In your JSON the outermost delimiter is an array bracket which means it's an anonymous array.  To reference the only record in the array you could provide the 'path' to...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: Read data from json file

    In the function JSON_VALUE 'path' is a required parameter and in the tvf OPENJSON 'path' is optional. The implementation of 'json path' in SQL Server is a limited subset of...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: how to calculate an average only if a minimum number of records exist?

    Where's your sample data?  A calendar table determines the workdays?  This is asking a bit.  Using AVG OVER can only accept literal numbers in the RANGE PRECEDING and afaik it...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: Sql script replace and rearrange numbers

    drew.allen wrote:

    You can combine the two deletes into a single delete.

    WITH Combine_Colors AS
    (
    SELECT *, ROW_NUMBER() OVER(PARTITION BY p.Airplane ORDER BY p.[Priority]) AS rn
    FROM #Priority AS p
    WHERE p.Color...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: Sql script replace and rearrange numbers

    Sorry, sorry my apologies.  I didn't catch the inconsistency.  The green arrows in the image you posted only point up!  Afaik that's the part I missed.  Once there's an accepted...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: Sql script replace and rearrange numbers

    Instead of 3 statements: "UPDATE Color, DELETE Color='White', UPDATE Priority", these 2 statements seem equivalent and simpler: "DELETE Color='White', UPDATE Color, Priority"

    NOTE: As per the post below the code...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: Sql script replace and rearrange numbers

    Happy Holidays to SSC!  Nicely done Phil.  Hmm... an issue which could potentially screw up the solution is the lack of constraint(s) on the input table.  Why are all of...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: How to speed up this query?

    That's a nice looking query Ken.  The OP's query used "SELECT ... INTO #TEMP1" which could be a bottleneck to a larger process imo.  Of course, it's not possible to...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: Group records during capture

    Bruin wrote:

    How could I last 15 minutes of activity pulling the unique record per minute

    Scroll up a few posts and see Ken McKelvey's reply.  Once t_stamp has been converted to...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: The Paradox of NOLOCK: How Dirty Reads Can Sometimes Be Cleaner

    Well, I admit I've never used NOLOCK in a query.  There hasn't been any project where NOLOCK is/was clearly required.  The article doesn't actually put forward any performance metrics or...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

Viewing 15 posts - 46 through 60 (of 1,419 total)