Forum Replies Created

Viewing 15 posts - 1,141 through 1,155 (of 2,171 total)

  • RE: Palindrome-SQL

    UPDATE Emp

    SET Status = CASE WHEN Ename = REVERSE(Ename) THEN 'Palindrome' ELSE ' No palindrome' END

  • RE: Palindrome-SQL

    UPDATE Table1

    SET Status = CASE WHEN Col1 = REVERSE(Col1) THEN 1 ELSE 0 END

  • RE: Convert a string of Number to Integer string

    AND ',' + @Line + ',' LIKE '%,' + DownlineLevel + ',%'

  • RE: query formation

    -- Ok!

    SELECTcb.batchid,

    sl.SName,

    sl.SType,

    sl.SDepartment,

    sl.OfficeHours,

    sl.SNotes,

    sl.SObjectives,

    sl.SComments,

    cl.cGraduatingYear,

    cl.cOptionType,

    cl.cDepartment1,

    cl.cDepartment2,

    cl.cStartDate,

    cl.cEndDate,

    cl.cObjectives,

    cl.cNotes,

    cl.cDiscipline1,

    cl.courseDiscipline2,

    cl.cDiscipline3,

    cl.cDiscipline4,

    cl.cDiscipline5

    FROMSignList AS sl

    LEFT JOINChurchList AS cl ON cl.ModuleID = sl.ModuleID

    LEFT JOINChurchBatch AS cb ON cb.ModuleID = sl.ModuleID

    WHEREsl.BatchID = '2333'

    ORDER BYsl.BatchID

    -- Not ok. ChurchList table is treated as INNER JOIN

    SELECTcb.batchid,

    sl.SName,

    sl.SType,

    sl.SDepartment,

    sl.OfficeHours,

    sl.SNotes,

    sl.SObjectives,

    sl.SComments,

    cl.cGraduatingYear,

    cl.cOptionType,

    cl.cDepartment1,

    cl.cDepartment2,

    cl.cStartDate,

    cl.cEndDate,

    cl.cObjectives,

    cl.cNotes,

    cl.cDiscipline1,

    cl.courseDiscipline2,

    cl.cDiscipline3,

    cl.cDiscipline4,

    cl.cDiscipline5

    FROMSignList...

  • RE: query formation

    Yes.

    It depends on the table alias for BATCH columns.

    If the alias is one of the two LEFT JOINS, the LEFT JOIN is treated as an INNER JOIN instead.

  • RE: SUM AND PRODUCT OF ROWS OF A SINGLE COLUMN

    Either exclude it from the SELECT like this

    SELECTSegmentID,

    EXP(SUM(LOG(FirstYield / 100.0))) AS [Total Yield],

    MIN(DayDate)

    FROMtblBuildPlan

    WHEREDayDate >= '2007-12-14'

    AND DayDate < '2007-12-17'

    AND FirstYield > 0

    GROUP BYSegmentIDor change the value {NULL, 0} to 1,...

  • RE: SUM AND PRODUCT OF ROWS OF A SINGLE COLUMN

    DECLARE@Sample TABLE (SegmentID INT, TestType VARCHAR(30), FirstYield NUMERIC(12, 4), Hour INT, DayDate DATETIME)

    SET DATEFORMAT MDY

    INSERT@Sample

    SELECT4, 'QA Inspection', 100.00, 12, '11/13/2007' UNION ALL

    SELECT4, 'Test Station', 100.00, 12, '11/16/2007' UNION ALL

    SELECT4, 'QA...

  • RE: SUM AND PRODUCT OF ROWS OF A SINGLE COLUMN

    Use logarithms.

    1*2*3*4*5*6 = 720

    DECLARE@Sample TABLE (i INT)

    INSERT@Sample

    SELECT1 UNION ALL

    SELECT2 UNION ALL

    SELECT3 UNION ALL

    SELECT4 UNION ALL

    SELECT5 UNION ALL

    SELECT6

    SELECTEXP(SUM(LOG(i)))

    FROM@Sample

  • RE: query formation

    The only thing missing is the table alias before the two references to BATCH column.

  • RE: TOP FUNCTION

    -- Prepare sample data

    DECLARE@Sample TABLE (Invoice CHAR(4), Account CHAR(4), Date DATETIME)

    SET DATEFORMAT DMY

    INSERT@Sample

    SELECT'inv1', 'acc1', '10/12/2007' UNION ALL

    SELECT'inv2', 'acc1', '11/12/2007' UNION ALL

    SELECT'inv3', 'acc1', '12/12/2007' UNION ALL

    SELECT'inv4', 'acc2', '11/12/2007' UNION ALL

    SELECT'inv5', 'acc2',...

  • RE: TOP FUNCTION

    DECLARE@Sample TABLE (Invoice CHAR(4), Account CHAR(4), Date DATETIME)

    SET DATEFORMAT DMY

    INSERT@Sample

    SELECT'inv1', 'acc1', '10/12/2007' UNION ALL

    SELECT'inv2', 'acc1', '11/12/2007' UNION ALL

    SELECT'inv3', 'acc1', '12/12/2007' UNION ALL

    SELECT'inv4', 'acc2', '11/12/2007' UNION ALL

    SELECT'inv5', 'acc2', '12/12/2007' UNION ALL

    SELECT'inv6',...

  • RE: TOP FUNCTION

    When is the assignment due?

    Don't worry. You will have a suggestion before that.

  • RE: Speeding up the initial query

    Also the SQL Server needs to create a query plan if it does not already exists in the query cache.

    The second time you run the query, both plan and possible...

  • RE: TOP FUNCTION

    Why would you not like this output?

    inv2 acc1 11/12/2007

    inv3 acc1 12/12/2007

    inv4 acc2 11/12/2007

    inv5 acc2 12/12/2007

    inv6 acc3 13/12/2007

Viewing 15 posts - 1,141 through 1,155 (of 2,171 total)