Forum Replies Created

Viewing 15 posts - 1,186 through 1,200 (of 1,228 total)

  • RE: Query Construction

    mail 41752 (1/23/2010)


    Can this be accomplished with a single SELECT statement...?

    Yes.

    DROP TABLE #Table1

    CREATE TABLE #Table1 (FieldA INT, FieldB INT)

    INSERT INTO #Table1 (FieldA, FieldB)...


    [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: Query multiple descriptions from single field of codes

    Here's a completely different way which returns the codes in the same row.

    CREATE TABLE #A (id INT, FCode CHAR(10))

    INSERT INTO #A

    SELECT...


    [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: Not getting desired results

    SELECT c.crs_id AS id,

    crs_name,

    crs_author,

    sch_start,

    sch_end,

    intro,

    recorded,

    edit_av,

    [time], ...


    [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: Query optimization

    lmu92 (1/23/2010)


    I would use the UNION operator (or even UNION ALL if possible) inside a CTE to get all values except AssetTypeName and join the CTE to the AssetType table.

    I...


    [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: Query optimization

    ALTER VIEW [dbo].[vw_AssetCommonDetail]

    AS

    SELECT d.AssetID, d.Location, d.Tower, d.[Floor], d.Cubicle, d.BaseVendor, d.Vendor, d.AssetType, d.AssetUser, a.AssetType

    FROM (

    SELECT DISTINCT AssetID, Location,Tower,[Floor],Cubicle, BaseVendor, Vendor, AssetType, AssetUser

    FROM Blackberry

    UNION

    SELECT DISTINCT AssetID,...


    [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 get only duplicate rows from table

    Strong hint!

    Write a query which returns the following result set:

    malli 2

    reddy 2

    - then post it here.


    [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 SERVER 2008 Pivot

    That's because @PivotCliPadres variable is too short, the value is truncated.

    However, @PivotCliPadres contains duplicate values, even if PIVOT can deal with this, it's almost certainly not what you want.

    Can I...


    [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: Integer bigger than bigint?

    We use three tables for this:

    an Item table with pk ItemID

    a Category table with pk CategoryID

    an ItemCategory table with pkItemCategory and fk's ItemID and CategoryID

    There are no limits (to...


    [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 SERVER 2008 Pivot

    NY, NY - so good they named it twice. Ok, are you entirely happy with these results? Is the data exactly what you would expect to see?


    [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: Sub Query returning multiple rows for particular inputs

    Those six correlated subqueries all point (correlate) to the same row in table tblstatusmaster, so why not change the query so that tblstatusmaster is LEFT JOINed in the FROM list...


    [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: Can I use UNPIVOT in this case?

    Could you use unpivot for this? I'm sure you could, if you were to pivot the data first. You don't need to, it's a very simple requirement:

    SELECT *

    FROM (

    ...


    [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: Procedure with variables Null should be all

    The LIKE is not necessary.

    WHERE o.uid = ISNULL(@Var, o.uid)

    AND indid IN (0, 1, 255)

    AND o.type = 'U'


    [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: Query-Select the first 5 characters in a field?

    This is probably a quick and dirty fix until your developer is available, but you could try the LEFT function as follows:

    select tm.Title, tm.primary_id ISBN13,

    cust_D, c.Name, Doc_Ref INVOICE_ID,

    isnull( sum(BO.DEL_QTY),0) BO_DEL_QTY,

    isnull(sum(BO.UNS_QTY),0)...


    [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 do you limit records using Distinct and Count - TOP and Rowcount dont work ?

    ifila (1/13/2010)


    I dont have a 'rowid' column on my table. Is the only solution to add this to my table as a workaround?

    No. You don't need it at all. But...


    [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 return rows with same value in one column and not same value in another column

    jmcnemar (1/11/2010)


    Thank you so much for the quick and plentiful responses. Chris, I tried your suggested code and it works pretty good except that I also need to exclude from...


    [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 - 1,186 through 1,200 (of 1,228 total)