Forum Replies Created

Viewing 15 posts - 1 through 15 (of 3,497 total)

  • Reply To: Radius Latitude Longitude

    You use the (longitude, latitude) to create/define a @Point. and then you use STDistance to calculate the distance between them.

    STDistance (geography Data Type) - SQL Server | Microsoft Learn

  • Reply To: String_agg not working as needed

    Day late probably, but one thing to remember is that

    <Aggregate> OVER (PARTITION BY <columnName>)

    is the windowing version of

    <Aggregate> FROM... GROUP BY <columnName>

    and windowing functions do not reduce the number of...

  • Reply To: String_agg not working as needed

    Something like this?

    SELECT  c.CustomerID, MAX(c.CallDate), STRING_AGG(c.Notes,' | ')
    FROM (VALUES
    (433, '2018-11-06 11:08:12.793', 'Customer called'),
    (433, '2018-11-06 11:08:12.793', 'Customer left...
  • Reply To: String_agg not working as needed

    Dave,

    Got some more data? Enough to weed out the false positives etc?

  • Reply To: String_agg not working as needed

    Like this?

    SELECT c.CustomerID, c.CallDate, STRING_AGG(c.Notes,'|')
    FROM (VALUES
    (433, '2018-11-06 11:08:12.793', 'Customer called'),
    (433, '2018-11-06 11:08:12.793', 'Customer left message')
    ) c(CustomerID, CallDate, Notes)
    GROUP...
  • Reply To: Dynamic Unpivot

    My code basically looks for the Causality or Relatedness columns and then counts back from there. That was the only sensible way of doing it. The weird 1/3 or whatever......

  • Reply To: Dynamic Unpivot

    just wondering. There's not really a way to achieve this without dynamic SQL, right? I don't think so because you don't know beforehand how many of the repeating groups there...

  • Reply To: how to write this query?

    Your sample desired output looks a lot like a PowerPivot in Excel. So I don't think trying to write a query for this is maybe what you want. (or is...

    • This reply was modified 2 weeks, 2 days ago by pietlinden. Reason: more information/clarification
    • This reply was modified 2 weeks, 2 days ago by pietlinden.
  • Reply To: Dynamic Unpivot

    Okay, I sorted it out. It's not ideal yet... It should be a stored procedure and should receive the tablename containing the data as input. Just because it's usually called...

  • Reply To: Dynamic Unpivot

    I was thinking of writing an iTVF to basically do the CROSS APPLY stuff for me. I'd do it tonight, but SQL Saturday is tomorrow... so I'll try it this...

  • Reply To: Dynamic Unpivot

    The basic pattern is SymptomName, Causality#, Relatedness#

    It's oncology stuff, so there are no other column names like that. Causality and Relatedness all have numeric suffixes from 1 to however many...

  • Reply To: Dynamic Unpivot

    The basic pattern is SymptomName, Causality#, Relatedness#

    It's oncology stuff, so there are no other column names like that. Causality and Relatedness all have numeric suffixes from 1 to however many...

  • Reply To: Dynamic Unpivot

    Oh, I STRING_AGG WITHIN GROUP was a good catch. Thanks for that!

    The bigger problem is that I have lots of tables with the same hideous design. That's what I was...

  • Reply To: Data Warehouse Toolkit meets Star Schema: The Complete Reference

    Funnily enough, I have that book too. Guess I should be brave and actually open it!

  • Reply To: Data Warehouse Toolkit meets Star Schema: The Complete Reference

    Kinda to answer my own question... I'd definitely recommend reading Star Schema: The Complete Reference before reading Data Warehouse Toolkit. Complete Reference starts from a much less theoretical place, so...

    • This reply was modified 1 months, 2 weeks ago by pietlinden.

Viewing 15 posts - 1 through 15 (of 3,497 total)