Forum Replies Created

Viewing 15 posts - 226 through 240 (of 1,413 total)

  • Reply To: Calculating Prime Numbers With One Query

    Jonathan AC Roberts wrote:

    Each number you test for primality needs O(sqrt(n)*n) calculations, so it will slow down for larger numbers. Also, if you increase @n to 10 times its previous value each...

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

  • Reply To: Calculating Prime Numbers With One Query

    Jonathan AC Roberts wrote:

    You only need to test up to the square root of a number to test for primality, which is quite a saving:

    declare @n   ...

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

  • Reply To: Calculating Prime Numbers With One Query

    Oh you're right.  This is not the final version but I'm not finding my notes on this.   Iirc if you follow the links it leads to a SQLlite script with...

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

  • Reply To: Calculating Prime Numbers With One Query

    For exhaustive methods it's quicker to only look at odd numbers.  There was a Youtube video a little while ago where they compared all different programming languages to determine which...

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

  • Reply To: Display columns from multiple rows in single

    Ok thanks.  Yeah maybe I misread this one.  When there are spaces in object labels it causes flashbacks to a difficult job

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

  • Reply To: Display columns from multiple rows in single

    Is the QUOTENAME to make the sample data?  🙂

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

  • Reply To: Display columns from multiple rows in single

    Looking at the first picture above the ordering of the Hours doesn't seem clear.  Is it ASCENDING by [Run Start Time]?  In the output, when the System value equals 6,...

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

  • Reply To: How Can I Speed This Query Up?

    Why settle a tie using query logic, what about a unique index?  Some or one of those could be helpful.  A table containing holidays to exclude could be useful too. ...

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

  • 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 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

Viewing 15 posts - 226 through 240 (of 1,413 total)