Forum Replies Created

Viewing 15 posts - 856 through 870 (of 1,228 total)

  • RE: Find all orders that have EXACTLY the same items

    Here's another version using APPLY without any sneaky tricks.

    DROP table #orders

    create table #orders(

    oid int,

    itemid int

    )

    insert into #orders (oid, itemid)

    values (1,1111)

    insert into #orders (oid, itemid)

    values (1,2222)

    insert into #orders (oid, itemid)

    values (1,3333)

    insert...


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]

  • RE: CASE vs. IF/ELSE in T-SQL ISNULL

    IF / ELSE is conditional processing of statements, so CASE would better match your requirements.

    You will need to provide a more complete explanation of conditions and outcomes for a...


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]

  • RE: Is NTILE OVER (PARTITION BY .. running total..) possible?

    virgilrucsandescu (5/2/2011)


    Thank you, tt works just perfect!

    Excuse my ignorance, but what's a "Quirky Update" ?

    Hi Virgil

    This link[/url] will show you an alternative set-based method of calculating running totals and introduce...


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]

  • RE: Are the posted questions getting worse?

    Koen Verbeeck (5/1/2011)


    ChrisM@home (4/30/2011)


    LutzM (4/30/2011)


    Slightly different over here in Germany: if a holiday falls on a Sunday (as it happens with May 1st this year), we won't get a public...


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]

  • RE: Is NTILE OVER (PARTITION BY .. running total..) possible?

    virgilrucsandescu (5/1/2011)


    Performance is not an issue in this case, I am just curious if just a set based solution is possible for this

    This is probably the simplest set-based solution. It's...


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]

  • RE: Is NTILE OVER (PARTITION BY .. running total..) possible?

    ColdCoffee (5/1/2011)


    Got it; Now, as Dixie says, either Quirky Update or Cursor can save you. I am still pondering if it will be possible by a Recursive-CTE..Got to think..

    A recursive...


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]

  • RE: SQL Running Subtraction

    Here's a solution right now. Never use code from a website without checking it first and fully understanding how it works - this article [/url]will explain the method used in...


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]

  • RE: Are the posted questions getting worse?

    Dave Ballantyne (4/30/2011)


    Yes indeed. Then Monday is a bank holiday. Nice long weekend for them

    Combined with the Easter Holiday last weekend as well, April is not going to be...


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]

  • RE: Are the posted questions getting worse?

    LutzM (4/30/2011)


    Slightly different over here in Germany: if a holiday falls on a Sunday (as it happens with May 1st this year), we won't get a public holiday during the...


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]

  • RE: How to avoid aggregate functions and TOP/BOTTOM ?

    OP appears to have lost interest :ermm:

    There's a solution to this without using TOP or any aggregate functions: variable assignment.

    This query

    DECLARE @curr tinyint, @ddate smalldatetime, @rate decimal(15, 4)

    SELECT @curr =...


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]

  • RE: How to avoid aggregate functions and TOP/BOTTOM ?

    In addition to the questions which Craig has asked, can you confirm which version of SQL Server you are using? This is the SQL Server 7, 2000 section.

    Cheers.


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]

  • RE: Table design to support move row up/move row down operations

    richard-674310 (4/28/2011)


    ... Is there some standard approach I am missing?

    This has been discussed on the forum before, I'll try to find the thread.


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]

  • RE: Select Random Row from a table

    If you have a sequential integer PK, then this is fast.

    SELECT *

    FROM TransactionDetail

    WHERE TransactionDetailID = (SELECT ABS(CHECKSUM(NEWID()))%100000+1)

    Replace 1000000 with the max ID in your table.


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]

  • RE: How can I round the number and remove decimal palces

    kuppurajm (4/27/2011)


    Hi,

    How can I round the number and remove decimal palces in sql server in simple way?

    EX:134.678

    I need result like this 135

    What result do you expect from 134.478?


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]

  • RE: Error in my SQL Statement

    Faye Fouladi (4/27/2011)


    thank you. Can you please tell me which string is bound by an extra quote?

    AND ca_d.name in (''AHLTA','Attachmate Reflection CHCS Companion with Public Keys',

    'Essentris','Dragon NaturallySpeaking','Nuance PDF...


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]

Viewing 15 posts - 856 through 870 (of 1,228 total)