Forum Replies Created

Viewing 15 posts - 691 through 705 (of 1,424 total)

  • Reply To: Query select.

    If the display order of the result set doesn't matter, using TOP(1) WITH TIES and ordering by the ROW_NUMBER

    select top(1) with ties *
    from #t1
    order by row_number() over...

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

  • Reply To: Splitting a group up into multiple groups using a score....

    Regarding the specifics of trading scenarios it's just not my cup of tea.  If there was a specific SQL question (or answer) without any lingo then maybe.  But so to...

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

  • Reply To: Getting sum of all transactions by month-end

    ;with
    loc_cte(loc) as (
    select distinct location
    from @tablom),
    n(n) as (
    select n
    from (values...

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

  • Reply To: Splitting a group up into multiple groups using a score....

    Thank you for your responses Rob.  It's an interesting story and your experiences with server code ring a bell which really resonates with me.  Ha, more could be said about...

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

  • Reply To: Splitting a group up into multiple groups using a score....

    Rob Reid-246754 wrote:

    So you think MONEY is a bad column for storing MONETARY values and that an INT which stores PENNIES (CENTS in US), is better. Is there a reason...

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

  • Reply To: Splitting a group up into multiple groups using a score....

    Thank you for your qualified thanks, I think.  You've been on this site for a long time so ok maybe something like this is helpful.

    declare
    @totalstake...

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

  • Reply To: Splitting a group up into multiple groups using a score....

    My apologies there was a mistake in the code.  You're correct there shouldn't be duplicates as you described.  In the 'xply_cte' CTE the 4th column contained an incorrect table alias. ...

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

  • Reply To: Splitting a group up into multiple groups using a score....

    It's not a good approach imo.  It's not necessary or polite to call anyone out.  For my part I'm not familiar with the terms and I'm generally uninterested in gambling. ...

    • This reply was modified 5 years, 7 months ago by Steve Collins. Reason: Fixed column alias in CTE

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

  • Reply To: Top 1 makes very fast query into very slow query

    You could maybe replace the whole WHILE LOOP'ing function with Eirikur's LEAD splitter.  If this is SQL Server 2016+ you could use the built-in STRING_SPLIT itvf (since the order...

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

  • Reply To: Top 1 makes very fast query into very slow query

    The query could be simplified, no?  Maybe something like this

    select top(1) p.AkcesAutoID
    from dbo.podrobnosti p
    join ro.fntStringsToTable('J') ltrs on ltrs.EvidenceLetter = p.EvidenceLetter
    ...

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

  • Reply To: Solving FIFO Queues Using Windowed Functions

    Here's another approach which uses a tally function to row multiply the 'Amount' column value(s) for both credits and debits.  A similar approach to FIFO calculation recently won some...

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

  • Reply To: Len

    [Edit] This is pretty much the same as Phil's code in the other thread with same name.

    with improper_cte(FirstName, LastName, DOB, ID) as (
    select...

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

  • Reply To: Len

    Instead of writing a query to do this crosstab would it be possible to go back to whatever code landed you at those 2 rows with different ID's in the...

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

  • Reply To: How can i do cumulative subtraction for the table based on multiple col's

    Here's something close but not matching because maybe there's an issue with the example results?  Could you explain for LID='L005' and EID='E002' how ALLO='21.00' and DAYSS='6.00' and then the RL...

    • This reply was modified 5 years, 8 months ago by Steve Collins. Reason: Added ORDER BY and simplified query

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

  • Reply To: DATEDIFF() for times over a day long

    A framework-ish way could be to use the awkward DATETIMEFROMPARTS and its 7 required parameters.

    declare
    @today [varchar](12) = '44:10:27.766',...

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

Viewing 15 posts - 691 through 705 (of 1,424 total)