Forum Replies Created

Viewing 15 posts - 6,286 through 6,300 (of 8,761 total)

  • RE: Row Counts Based on Distinct Values from Multiple Tables

    For fun, few different counts/metrics

    😎

    USE tempdb;

    GO

    SET NOCOUNT ON;

    ;with UnionTables as

    (

    SELECT CAST(TestDateTime AS Date) TestDate,

    SerialNumber,

    TestType

    FROM Coat

    UNION ALL

    SELECT CAST(TestDateTime AS Date) TestDate,

    SerialNumber,

    TestType

    FROM Cutoff

    UNION ALL

    SELECT CAST(TestDateTime AS Date) TestDate,

    SerialNumber,

    TestType

    FROM Geo

    UNION ALL

    SELECT CAST(TestDateTime AS...

  • RE: Tipping point for a numbers table vs inline tally

    sqldriver (1/15/2015)


    Yeah, I just do this and replace the TOP with whatever target number.

    USE tempdb

    DECLARE @cntr BIGINT = 0;

    ;WITH T(N) AS (SELECT N FROM (VALUES (NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL)) AS X(N))

    ,NUMS(N) AS...

  • RE: Row Counts Based on Distinct Values from Multiple Tables

    Many ways of doing this, here is one

    😎

    USE tempdb;

    GO

    SET NOCOUNT ON;

    DECLARE @SAMPLE_DATA TABLE

    (

    [Date] DATE ...

  • RE: Are the posted questions getting worse?

    Koen Verbeeck (1/14/2015)


    Luis Cazares (1/14/2015)


    Congratulations Koen! When I grow up I want to be like you. :hehe:

    Action figures will soon be available! 😎

    Certainly there is a branded Witbier on it's...

  • RE: Is there a better way to write this query.

    Quick though, unless you have an under-performing/resource starved system, 10000 sounds like a very small number for an insert batch size, any particular reason for this number? Cannot see it...

  • RE: MIN across multiple columns with a GROUP BY

    kiran 4243 (1/13/2015)


    Hi,

    How to get the lowest U.Price along with FX and Rate.

    ID-U.Price-FX-Rate

    1280 19.1196 EUR 3.85

    1280 46.2462 USD 3.63

    1280 6.32 RM 1.00

    Required output.

    ID-U.Price-FX-Rate

    1280...

  • RE: Are the posted questions getting worse?

    Koen Verbeeck (1/13/2015)


    FYI, I received the Author of the Year award at MSSQLTips.com!

    Thanks everyone for voting!

    Congratulations, good job and well done, justly deserved I would say!

    😎

  • RE: How to add missing IDs in a SQL table?

    srinivas.akyana (1/12/2015)


    Hello,

    I have a scenario where I would need to add +4 IDs with the existing IDs, below is an example:

    IDWorkloadUnits

    1EXO 3

    7SPO ...

  • RE: IMPLICIT_TRANSACTIONS & BEGIN TRAN

    Thomas Abraham (1/12/2015)


    Hugo Kornelis (1/12/2015)


    I thought that using SELECT would have started the implicit transaction, but I tested after answering this question and nothing changes if I use SELECT instead...

  • RE: Help With Trying to Import File Names into a Table

    Polymorphist (1/9/2015)


    Folks i'm dead in the water here - can anyone help at all? Nothing I try works and I have a feeling i'm overlooking something very simple.

    Quick thought,...

  • RE: Running Totals

    Quick partial solution, missing the handling of negative stock count though.

    😎

    SELECT w.ItemId

    ,w.DateID

    ,w.OpenningWareHouseUnits

    ,w.FcastSales

    ,w.GoodsIncoming

    ,w.TargetRunningStock

    , SUM((ISNULL(w.OpenningWareHouseUnits,0) + ISNULL(w.GoodsIncoming,0)) - w.FcastSales) OVER

    ...

  • RE: Tiered Commission Plan

    Quick simple solution, note that the output is not formatted but that's easy

    😎

    USE tempdb;

    GO

    SET NOCOUNT ON;

    --INVOICE DATA

    IF OBJECT_ID('tempdb..#RawData') IS NOT NULL DROP TABLE #RawData;

    CREATE TABLE #RawData (Invoice varchar(7), Quantity int,...

  • RE: How to model a slowly changing dimension

    Quick questions, are these assumptions correct?

    😎

    1) Definition: Territory is a Geographical Area, defined by a collection of Zip Codes, each of which represents either a Geographical or a Pseudo location....

  • RE: search date field by partial date?

    Slightly simpler solution for SQL Server 2008 and later, produces the same results

    😎

    declare @pSomeDate as varchar(20) = '04/2011';

    SELECT

    recid

    ,weeknumber

    ,title

    ...

  • RE: Assistance with an IF THEN in SQL Sever 2008 R2?

    chef423 (1/11/2015)


    hmmm, that's why I put the output of the above code in the thread...

    No worries...Ill figure it out on my own then.

    If you don't understand the original code then...

Viewing 15 posts - 6,286 through 6,300 (of 8,761 total)