Forum Replies Created

Viewing 15 posts - 241 through 255 (of 1,419 total)

  • Reply To: SQL help with partition

    Doh, well I'd like to edit my edit in the previous post.  Instead of "Removed IN from WHERE clause" it should say "Removed IN from WHEN condition" or something like...

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

  • Reply To: SQL help with partition

    Maybe add a boolean column to the partition

    select *, v.grp,
    [test33] = case when v.grp=1
    ...

    • This reply was modified 3 years, 3 months ago by Steve Collins. Reason: Removed IN from WHERE clause

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

  • Reply To: SQL Query

    Thanks to ChatGPT for creating the temp table

    DROP TABLE if exists #TempTable;
    go
    CREATE TABLE #TempTable
    (
    ID INT,
    flag int,
    ...

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

  • Reply To: Advanced SQL query help

    For the first query ChatGPT-4 generated

    WITH CompanyAverageRent AS (
    SELECT c.CompanyId, AVG(p.Rent) AS AverageRent
    FROM #Companies c
    JOIN...

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

  • Reply To: Query to Insert Data Based on CustomerID from one table to another

    What happens if/when there are gaps in the CreatedDate column for particular CustomerID's?

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

  • Reply To: Are the posted questions getting worse?

    additional JOIN's and CROSS APPLY's apply to the rectangle defined immediately above it (in order of appearance) within the FROM clause

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

  • Reply To: Are the posted questions getting worse?

    Dennis Jensen wrote:

    Thinking outside the box is part of the reason I can solve problems fairly quickly as I use approaches that are not always predefined.

    Thinking inside rectangles is how I...

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

  • Reply To: Are the posted questions getting worse?

    Steve Jones - SSC Editor wrote:

    The link Steve Collins posted is interesting. Got through it, and while I don't quite agree that stored procs create a strangler pattern, I do think in the high...

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

  • Reply To: Are the posted questions getting worse?

    Check out this video.  The speaker gives a whole laundry list of reasons, a litany of epiphanies, on why SQL Server is not well suited for transaction processing.  Instead, the...

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

  • Reply To: How to return '0' for no rows (no information) in the table

    It seems you could use COUNT in the SELECT list.  COUNT always returns an INT even if the FROM clause returns no rows

    declare
    @max_num ...

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

  • Reply To: SQL Query Modification

    This is a tricky query.  You have 2 separate aggregations for which the results are then LEFT JOIN'ed by rank.  What I'm not understanding in my own code is why...

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

  • Reply To: Dirty Reads with Read Committed?

    Does the query contain WITH (NOLOCK)?

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

  • Reply To: Grouping the words which has maximum count

    sathishkm wrote:

    Msg 8144, Level 16, State 3, Line 38 Procedure or function string_split has too many arguments specified.

    Completion time: 2023-05-08T16:53:02.0901322+05:30

    Please run this code and paste the results.  Please replace 'Your-Database-Name'...

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

  • Reply To: Grouping the words which has maximum count

    An alternative

    drop table if exists #title_one_space;
    go
    select * into #title_one_space from (values
    ('one word')
    ,('one word two words')
    ,('one word two words three words')
    ,('one word two words three words four'))...

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

  • Reply To: Peaks and troughs from fluctuating prices

    It shouldn't be necessary to calculate the LAG twice.  Like Drew's code this factors out another CTE

      WITH 
    ctePrev AS
    (--==== Get the previous Prices...

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

Viewing 15 posts - 241 through 255 (of 1,419 total)