Forum Replies Created

Viewing 15 posts - 1,741 through 1,755 (of 2,838 total)

  • RE: Select Only IDs that match all entries in another table

    Brandie Tarvin (5/17/2011)


    Stefan,

    I've actually had to do that at my work place. If those solutions don't work for some reason, let us know and I'll check my production environment to...

    --------------------------------------
    When you encounter a problem, if the solution isn't readily evident go back to the start and check your assumptions.
    --------------------------------------
    It’s unpleasantly like being drunk.
    What’s so unpleasant about being drunk?
    You ask a glass of water. -- Douglas Adams

  • RE: Select rows from table that don exist in another with where clause

    CELKO (5/17/2011)


    Please post real DDL. Learn to use ISO-11179 rules for the data element names, avoid needless dialect and use ISO-8601 temporal formats, codes and so forth. People cannot read...

    --------------------------------------
    When you encounter a problem, if the solution isn't readily evident go back to the start and check your assumptions.
    --------------------------------------
    It’s unpleasantly like being drunk.
    What’s so unpleasant about being drunk?
    You ask a glass of water. -- Douglas Adams

  • RE: Select rows from table that don exist in another with where clause

    CELKO (5/17/2011)


    Please post real DDL. Learn to use ISO-11179 rules for the data element names, avoid needless dialect and use ISO-8601 temporal formats, codes and so forth. People cannot read...

    --------------------------------------
    When you encounter a problem, if the solution isn't readily evident go back to the start and check your assumptions.
    --------------------------------------
    It’s unpleasantly like being drunk.
    What’s so unpleasant about being drunk?
    You ask a glass of water. -- Douglas Adams

  • RE: Select Only IDs that match all entries in another table

    Gianluca Sartori (5/17/2011)


    Well, actually you don't need a CTE, but you could tweak Howard's code to take the distinct into account:

    SELECT SaleID FROM #SalesDetails sd

    INNER JOIN #ProdList ON sd.ProductID =...

    --------------------------------------
    When you encounter a problem, if the solution isn't readily evident go back to the start and check your assumptions.
    --------------------------------------
    It’s unpleasantly like being drunk.
    What’s so unpleasant about being drunk?
    You ask a glass of water. -- Douglas Adams

  • RE: Select Only IDs that match all entries in another table

    Gianluca Sartori (5/17/2011)


    Something like this should do:

    ;WITH Sales AS (

    SELECT SaleId, COUNT(DISTINCT ProductId) AS DistinctProducts

    FROM #SalesDetails

    WHERE ProductId IN (SELECT ProductId FROM #ProdList)

    GROUP BY SaleId

    ),

    Products AS (

    SELECT COUNT(DISTINCT ProductId) AS DistinctProducts

    FROM...

    --------------------------------------
    When you encounter a problem, if the solution isn't readily evident go back to the start and check your assumptions.
    --------------------------------------
    It’s unpleasantly like being drunk.
    What’s so unpleasant about being drunk?
    You ask a glass of water. -- Douglas Adams

  • RE: Select Only IDs that match all entries in another table

    HowardW (5/17/2011)


    Can a productID exist multiple times for a single SaleID? If not, you could do something like the below:

    SELECT SaleID FROM #SalesDetails sd

    INNER JOIN #ProdList ON sd.ProductID = #ProdList.ProductID

    GROUP...

    --------------------------------------
    When you encounter a problem, if the solution isn't readily evident go back to the start and check your assumptions.
    --------------------------------------
    It’s unpleasantly like being drunk.
    What’s so unpleasant about being drunk?
    You ask a glass of water. -- Douglas Adams

  • RE: Are the posted questions getting worse?

    If I may, I'd like to request assistance on a question of mine here

    http://www.sqlservercentral.com/Forums/Topic1110359-392-1.aspx

    --------------------------------------
    When you encounter a problem, if the solution isn't readily evident go back to the start and check your assumptions.
    --------------------------------------
    It’s unpleasantly like being drunk.
    What’s so unpleasant about being drunk?
    You ask a glass of water. -- Douglas Adams

  • RE: Select rows from table that don exist in another with where clause

    OK, this should get all the initials that aren't in a given period

    create table #tTimetable (DayID int, PeriodID int, StaffID int);

    insert into #tTimetable(DayID, PeriodID, StaffID)

    values

    (1,1,2),

    (1,1,7),

    (1,1,8),

    (1,1,9),

    (1,2,6),

    (1,2,7),

    (1,2,8),

    (1,2,9),

    (1,3,1),

    (1,3,2),

    (1,3,3),

    (1,3,4),

    (1,3,5),

    (1,3,6),

    (1,3,7)

    create table #tStaffTimeTableInfo (StaffID int,...

    --------------------------------------
    When you encounter a problem, if the solution isn't readily evident go back to the start and check your assumptions.
    --------------------------------------
    It’s unpleasantly like being drunk.
    What’s so unpleasant about being drunk?
    You ask a glass of water. -- Douglas Adams

  • RE: Select rows from table that don exist in another with where clause

    toddasd (5/17/2011)


    Stefan, your solution lists the staff members for that particular periodID. It seems to me he wants the staff that are not matched.

    Oops, sorry about that. I'll go fix...

    --------------------------------------
    When you encounter a problem, if the solution isn't readily evident go back to the start and check your assumptions.
    --------------------------------------
    It’s unpleasantly like being drunk.
    What’s so unpleasant about being drunk?
    You ask a glass of water. -- Douglas Adams

  • RE: Select rows from table that don exist in another with where clause

    This should do it, I think

    create table #tTimetable (DayID int, PeriodID int, StaffID int);

    insert into #tTimetable(DayID, PeriodID, StaffID)

    values

    (1,1,2),

    (1,1,7),

    (1,1,8),

    (1,1,9),

    (1,2,6),

    (1,2,7),

    (1,2,8),

    (1,2,9),

    (1,3,1),

    (1,3,2),

    (1,3,3),

    (1,3,4),

    (1,3,5),

    (1,3,6),

    (1,3,7)

    create table #tStaffTimeTableInfo (StaffID int, StaffInitials varchar(10));

    insert into #tStaffTimeTableInfo(StaffID, StaffInitials)

    values

    (1,'ABC'),

    (2,'RWT'),

    (3,'YUJ'),

    (4,'OPP'),

    (5,'QWE'),

    (6,'TFV'),

    (7,'ASA'),

    (8,'MNB'),

    (9,'PLM')

    CREATE TABLE...

    --------------------------------------
    When you encounter a problem, if the solution isn't readily evident go back to the start and check your assumptions.
    --------------------------------------
    It’s unpleasantly like being drunk.
    What’s so unpleasant about being drunk?
    You ask a glass of water. -- Douglas Adams

  • RE: Are the posted questions getting worse?

    LutzM (5/16/2011)


    Stefan Krzywicki (5/16/2011)


    Here's an interesting article on Oracle satisfaction[/url]

    SQL Server's not even mentioned, I guess we have a way to go in being considered suitable for very large databases....

    --------------------------------------
    When you encounter a problem, if the solution isn't readily evident go back to the start and check your assumptions.
    --------------------------------------
    It’s unpleasantly like being drunk.
    What’s so unpleasant about being drunk?
    You ask a glass of water. -- Douglas Adams

  • RE: Are the posted questions getting worse?

    GSquared (5/16/2011)


    Peoplesoft and JD Edwards are Oracle products, not Oracle competitors. The survey was about Oracle products, not just about their database engine, so it would naturally include both of...

    --------------------------------------
    When you encounter a problem, if the solution isn't readily evident go back to the start and check your assumptions.
    --------------------------------------
    It’s unpleasantly like being drunk.
    What’s so unpleasant about being drunk?
    You ask a glass of water. -- Douglas Adams

  • RE: Are the posted questions getting worse?

    GSquared (5/16/2011)


    Stefan Krzywicki (5/16/2011)


    GSquared (5/16/2011)


    Stefan Krzywicki (5/16/2011)


    Here's an interesting article on Oracle satisfaction[/url]

    SQL Server's not even mentioned, I guess we have a way to go in being considered suitable for...

    --------------------------------------
    When you encounter a problem, if the solution isn't readily evident go back to the start and check your assumptions.
    --------------------------------------
    It’s unpleasantly like being drunk.
    What’s so unpleasant about being drunk?
    You ask a glass of water. -- Douglas Adams

  • RE: Are the posted questions getting worse?

    GSquared (5/16/2011)


    Stefan Krzywicki (5/16/2011)


    Here's an interesting article on Oracle satisfaction[/url]

    SQL Server's not even mentioned, I guess we have a way to go in being considered suitable for very large databases....

    --------------------------------------
    When you encounter a problem, if the solution isn't readily evident go back to the start and check your assumptions.
    --------------------------------------
    It’s unpleasantly like being drunk.
    What’s so unpleasant about being drunk?
    You ask a glass of water. -- Douglas Adams

  • RE: Are the posted questions getting worse?

    Brandie Tarvin (5/16/2011)


    Stefan Krzywicki (5/16/2011)


    Brandie Tarvin (5/16/2011)


    Stefan Krzywicki (5/16/2011)


    Here's an interesting article on Oracle satisfaction[/url]

    SQL Server's not even mentioned, I guess we have a way to go in being considered...

    --------------------------------------
    When you encounter a problem, if the solution isn't readily evident go back to the start and check your assumptions.
    --------------------------------------
    It’s unpleasantly like being drunk.
    What’s so unpleasant about being drunk?
    You ask a glass of water. -- Douglas Adams

Viewing 15 posts - 1,741 through 1,755 (of 2,838 total)