Forum Replies Created

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

  • Reply To: T-SQL Parent Child

    Hey there why so hasty?  If you'd fixed the script we might've seen some JM t-SQL  It's been a while afaik :).  The query seems nicely done tho.  Presumably uniqueness...

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

  • Reply To: T-SQL Parent Child

    ringovski wrote:

    I have 5 country grouping tables with PK & FK foriegn key relationships that store master group names and sub group names each with the relevant country id.

    There are...

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

  • Reply To: Update particular record in a table

    Afaik there are only two possible values for the Category column: { 'Lessthan8', 'greatherthan8' }.  If that's so the query could rely on EXISTS to handle any duplication

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

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

    Regarding the precision of the data types

    cast(Price as decimal(9,7)) Calculation

    The line above CAST's the price (Price) to DECIMAL(9, 7).  Imo this is not a good practice.  When...

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

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

    My query was insufficient because it applied the factor percentage to the lagged price and not to the lagged calculated price.  It seems recursion is unavoidable.  This query uses a...

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

  • 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

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