Forum Replies Created

Viewing 15 posts - 16 through 30 (of 133 total)

  • RE: Split a number in close equal number in sql

    I want to divide 11 into 4 groups then output should be 3,3,3,2. same way 10 for for group would be 3,3,2,2. ..

    Look up the NTILE() function.

    Books in Celko Series for Morgan-Kaufmann Publishing
    Analytics and OLAP in SQL
    Data and Databases: Concepts in Practice
    Data, Measurements and Standards in SQL
    SQL for Smarties
    SQL Programming Style
    SQL Puzzles and Answers
    Thinking in Sets
    Trees and Hierarchies in SQL

  • RE: GROUP BY in SQL Server 2014

    its working ok with ORDER BY and the same results are been returned...

    what does that mean though? that you always have to insert ORDER BY ?

    You are missing some fundamental...

    Books in Celko Series for Morgan-Kaufmann Publishing
    Analytics and OLAP in SQL
    Data and Databases: Concepts in Practice
    Data, Measurements and Standards in SQL
    SQL for Smarties
    SQL Programming Style
    SQL Puzzles and Answers
    Thinking in Sets
    Trees and Hierarchies in SQL

  • RE: Query to join three tables but filter out subset of the data

    It wouldn't be SSN, because (1) that can change and (2) it might not technically be legal in certain use cases for a private company to use that.

    Yes, but...

    Books in Celko Series for Morgan-Kaufmann Publishing
    Analytics and OLAP in SQL
    Data and Databases: Concepts in Practice
    Data, Measurements and Standards in SQL
    SQL for Smarties
    SQL Programming Style
    SQL Puzzles and Answers
    Thinking in Sets
    Trees and Hierarchies in SQL

  • RE: Query to join three tables but filter out subset of the data

    >> For simplicity sake, say we have the following tables:<<

    It would have been simpler if you posted real DDL, complete with constraints keys and references. What we have here is...

    Books in Celko Series for Morgan-Kaufmann Publishing
    Analytics and OLAP in SQL
    Data and Databases: Concepts in Practice
    Data, Measurements and Standards in SQL
    SQL for Smarties
    SQL Programming Style
    SQL Puzzles and Answers
    Thinking in Sets
    Trees and Hierarchies in SQL

  • RE: Confusion Over OR and And Operators

    Get a book on logic and read the section on DeMorgan's Laws. But be careful! SQL has three value logic (true, false, unknown), and things do not always work the...

    Books in Celko Series for Morgan-Kaufmann Publishing
    Analytics and OLAP in SQL
    Data and Databases: Concepts in Practice
    Data, Measurements and Standards in SQL
    SQL for Smarties
    SQL Programming Style
    SQL Puzzles and Answers
    Thinking in Sets
    Trees and Hierarchies in SQL

  • RE: Find all dates between date ranges in a table; Prefer tally table solution

    We really need to turn what you posted into an actual table. That means keys, constraints, etc.

    CREATE TABLE Date_Ranges

    (start_date DATE NOT NULL,

    end_date DATE NOT NULL,

    PRIMARY KEY (start_date,...

    Books in Celko Series for Morgan-Kaufmann Publishing
    Analytics and OLAP in SQL
    Data and Databases: Concepts in Practice
    Data, Measurements and Standards in SQL
    SQL for Smarties
    SQL Programming Style
    SQL Puzzles and Answers
    Thinking in Sets
    Trees and Hierarchies in SQL

  • RE: effective use of subquery with a where condition

    constraining this type of column to be NOT NULL would seem to eliminate the possibility of representing an unknown value, or are you suggesting that everything should be in...

    Books in Celko Series for Morgan-Kaufmann Publishing
    Analytics and OLAP in SQL
    Data and Databases: Concepts in Practice
    Data, Measurements and Standards in SQL
    SQL for Smarties
    SQL Programming Style
    SQL Puzzles and Answers
    Thinking in Sets
    Trees and Hierarchies in SQL

  • RE: effective use of subquery with a where condition

    How many times do you have to be reminded that T-SQL does not support the Boolean data type that ANSI SQL recommends in place of the bit flag?

    [/quote]

    Actually, I...

    Books in Celko Series for Morgan-Kaufmann Publishing
    Analytics and OLAP in SQL
    Data and Databases: Concepts in Practice
    Data, Measurements and Standards in SQL
    SQL for Smarties
    SQL Programming Style
    SQL Puzzles and Answers
    Thinking in Sets
    Trees and Hierarchies in SQL

  • RE: Query optimization

    Now you're just making up stuff to support your claims.

    No, I get called in every now and then by product developers a lot of different SQL companies to make...

    Books in Celko Series for Morgan-Kaufmann Publishing
    Analytics and OLAP in SQL
    Data and Databases: Concepts in Practice
    Data, Measurements and Standards in SQL
    SQL for Smarties
    SQL Programming Style
    SQL Puzzles and Answers
    Thinking in Sets
    Trees and Hierarchies in SQL

  • RE: Query optimization

    You know that we have two options, either portable code or fast code. You can't have both.

    No, I do not know that because the building entire career on...

    Books in Celko Series for Morgan-Kaufmann Publishing
    Analytics and OLAP in SQL
    Data and Databases: Concepts in Practice
    Data, Measurements and Standards in SQL
    SQL for Smarties
    SQL Programming Style
    SQL Puzzles and Answers
    Thinking in Sets
    Trees and Hierarchies in SQL

  • RE: effective use of subquery with a where condition

    >> see script below: <<

    We need to see the DDL. Did you read the forum rules before you posted? What you have posted is really awful. You do not know...

    Books in Celko Series for Morgan-Kaufmann Publishing
    Analytics and OLAP in SQL
    Data and Databases: Concepts in Practice
    Data, Measurements and Standards in SQL
    SQL for Smarties
    SQL Programming Style
    SQL Puzzles and Answers
    Thinking in Sets
    Trees and Hierarchies in SQL

  • RE: Unexpected Behavior With TOP clause in a DELETE

    I would like you to think about the proprietary syntax and what it really means. Essentially, although you probably do not know know it, you are doing a nineteen fifties...

    Books in Celko Series for Morgan-Kaufmann Publishing
    Analytics and OLAP in SQL
    Data and Databases: Concepts in Practice
    Data, Measurements and Standards in SQL
    SQL for Smarties
    SQL Programming Style
    SQL Puzzles and Answers
    Thinking in Sets
    Trees and Hierarchies in SQL

  • RE: Query optimization

    >> I want to optimise the following query that is running so slowly. <<

    First of all, we need some DDL what you did post is really bad. You put...

    Books in Celko Series for Morgan-Kaufmann Publishing
    Analytics and OLAP in SQL
    Data and Databases: Concepts in Practice
    Data, Measurements and Standards in SQL
    SQL for Smarties
    SQL Programming Style
    SQL Puzzles and Answers
    Thinking in Sets
    Trees and Hierarchies in SQL

  • RE: possible combinations for all rows in table

    Still trying to figure out what he really wants, but I am thinking maybe this is a linear programming problem? Let us be honest, SQL is not really good at...

    Books in Celko Series for Morgan-Kaufmann Publishing
    Analytics and OLAP in SQL
    Data and Databases: Concepts in Practice
    Data, Measurements and Standards in SQL
    SQL for Smarties
    SQL Programming Style
    SQL Puzzles and Answers
    Thinking in Sets
    Trees and Hierarchies in SQL

  • RE: recursive query to find out orphans

    Correct minor typos:

    INSERT INTO Forest

    VALUES

    ('Root',1,8),

    ('first child of root',2, 5),

    ('first child of first child of root',3,4),

    ('second child of root', 6,7),

    --- this has to be forced in a nested sets model

    ('orphan',...

    Books in Celko Series for Morgan-Kaufmann Publishing
    Analytics and OLAP in SQL
    Data and Databases: Concepts in Practice
    Data, Measurements and Standards in SQL
    SQL for Smarties
    SQL Programming Style
    SQL Puzzles and Answers
    Thinking in Sets
    Trees and Hierarchies in SQL

Viewing 15 posts - 16 through 30 (of 133 total)