Forum Replies Created

Viewing 15 posts - 46 through 60 (of 3,956 total)

  • RE: Are the posted questions getting worse?

    SQLRNNR (5/20/2015)


    Ed Wagner (5/20/2015)


    GilaMonster (5/20/2015)


    Eirikur Eiriksson (5/20/2015)


    This would be the one that wants to fix ugly queries with a sprinkle of hint perfume when all that's needed is a good...

  • RE: Is there an equivalent of Excel's NORMDIST function in SQL Server 2005?

    Nothing out of the box as stated, but there is this:

    Excel in T-SQL Part 2 – The Normal Distribution (NORM.DIST) Density Functions[/url]

    There are also some links at the end to...

  • RE: Selecting days in month between two dates

    Many ways to do this, some of which may be a little more obvious than others. Here's another:

    DECLARE @Sample TABLE(

    FileNumb int,

    ...

  • RE: Help with a SQL Query

    th02b0 (5/19/2015)


    IN PUT:

    EmployeeID-----Shift-----Month----Year-----D1-----D2------D3

    NV01---------------A1-------5---------2015----True----False---True

    NV01---------------A2-------5---------2015----False---True----False

    NV02---------------A1-------4---------2015----True----True----True

    OUT PUT:

    EmployeeID----Shift-------Date------------Value

    NV01--------------A1------2015-05-01--------True

    NV01--------------A1------2015-05-02--------False

    NV01--------------A1------2015-05-03--------True

    NV02--------------A1------2015-04-01--------True

    NV02--------------A1------2015-04-02--------True

    NV02--------------A1------2015-04-03--------True

    NV01--------------A2------2015-05-01--------False

    NV01--------------A2------2015-05-02--------True

    NV01--------------A2------2015-05-03--------False

    Thanks

    This should be straightforward enough to do, but since you did not supply DDL (sample table) and some consumable INSERTs of your data into that sample data,...

  • RE: Skipping group with FOR XML Path('')

    For example, here's a proper test harness that covers 3 indexing scenarios (there may be others):

    CREATE TABLE #Test

    (

    id INT ...

  • RE: Skipping group with FOR XML Path('')

    pdanes (5/19/2015)


    That was a question, not a conclusion. Notice the question mark at the end of the first sentence.

    Yes I did, but I'm not in the habit of answering...

  • RE: Skipping group with FOR XML Path('')

    pdanes (5/19/2015)


    dwain.c (5/18/2015)


    Another way:

    SELECT *

    INTO #Test

    FROM (Values

    (1, 'A'),

    (1, 'B'),

    (1, 'C'),

    (1, 'D'),

    (1, 'E'),

    (2, 'A'),

    (2, 'C'),

    (2, 'D'),

    (2, 'E'),

    (3, 'A'),

    (3, 'B'),

    (3, 'C'),

    (3, 'F'),

    (4, 'A'),

    (4, 'B'),

    (4, 'D'),

    (4, 'F'),

    (4, 'G'))x(id, value);

    SELECT id

    ...

  • RE: To get Top 10

    Here's an example that illustrates what happens when you want the TOP 5 and ties are present.

    WITH SampleData (Custid, department, location, revenue) AS

    (

    SELECT 1, 'Fin','NY',...

  • RE: Skipping group with FOR XML Path('')

    Another way:

    SELECT *

    INTO #Test

    FROM (Values

    (1, 'A'),

    (1, 'B'),

    (1, 'C'),

    (1, 'D'),

    (1, 'E'),

    (2, 'A'),

    (2, 'C'),

    (2, 'D'),

    (2, 'E'),

    (3, 'A'),

    (3, 'B'),

    (3, 'C'),

    (3, 'F'),

    (4, 'A'),

    (4, 'B'),

    (4, 'D'),

    (4, 'F'),

    (4, 'G'))x(id, value);

    SELECT id

    ,value=STUFF(

    ...

  • RE: How to choose which row to use

    Every time I see a question that involves students or grades, I think "homework!"

  • RE: When Invoice contains multiple values Set value equal to a value

    brianconner (5/18/2015)


    All I have a table full of invoices and in that table there is a field named HCC. An invoice can contain multiple HCC's.

    I also have a table...

  • RE: QUESTION ABOUT MULTIPLE EXCEPT STATEMENTS

    Jeff Moden (5/17/2015)


    I don't understand why people post such questions instead of just trying it.

    That's what I would do.

    Of course, then Eirikur would have no fun posting up...

  • RE: Running totals for previous X days

    Luis Cazares (5/14/2015)


    I was wondering, why would you have a value before an event happened? Shouldn't you have zeros until the first real occurrence?

    I confess to wondering the same thing.

  • RE: unusual syntax - is this deprecated

    I gotta wonder what the ANSI standards say about this one!

    Never seen anything like it before, but I will take note when writing my "Obfuscasting SQL" book! Looks better...

  • RE: Run SQL query to retrieve 650 unique records

    I do this all the time.

    1. Create a column in your spreadsheet where you will build the SQL you need.

    2. Enter the cell formula shown in B2 (above)

    3. Copy that...

Viewing 15 posts - 46 through 60 (of 3,956 total)