Forum Replies Created

Viewing 15 posts - 1 through 15 (of 32 total)

  • Reply To: Create a View with Index

    Thank you for all the inputs - the execution time on this and a number of other queries has been greatly improved.

    It seems that there is not always 1 solution...

  • Reply To: Create a View with Index

    Update - all ctes removed - execution 00:00:02

    SELECT      jh.Company, jh.JobNum, ja.AssemblySeq, jo.OprSeq, jo.OpCode, ja.FinalOpr, jo.EstSetHours, jo.EstProdHours, jo.ProdStandard, jo.StdFormat, 
    ...
  • Reply To: Create a View with Index

    Update - I have rewritten SubQuery2 and SubQuery3 as OUTER APPLY and tested.

    Results set is correct and execution is 00:00:01.

    The removal of the last cte is proving more problematic and...

  • Reply To: Create a View with Index

    Update - figured out where to place the code snippet:

    Using the Outer Apply 28,000 records 00:00:01

    Using the SubQuery 28,000 records 00:00:02

  • Reply To: Create a View with Index

    From a performance point of view I'm honestly not sure but from a logical point of view this can be simplified to jh.ProdQty > jh.QtyCompleted.

     

  • Reply To: Create a View with Index

    Apologies - not sure where to place:

    WITH SubQuery AS
    (
    SELECTjh.Company, jh.JobNum, ja.AssemblySeq, jo.OprSeq, jo.OpCode,
    CAST(CASE WHEN...
  • Reply To: Create a View with Index

    As part of testing I removed the JobHead and JobAsmbl tables from both SubQuery statements but the execution jumped from 00:00:01 to return 28,800 records to 00:00:06.

    The JobOper and JobMtl...

  • Reply To: Create a View with Index

    Not sure where to place this code segment - can you advise.

    I receive and error: Incorrect syntax near the keyword 'ON' having slotted it after SubQuery and part of SubQuery2.

  • This reply was modified 3 years, 4 months ago by  robertopmorris.
  • Reply To: Create a View with Index

    Execution on the cte is 00:00:00 returning 1662 rows.

    My biggest issue now is building up a data set with multiple aggregate values and accomplishing this without reducing performance.

    I am currently...

  • Reply To: Create a View with Index

    The cte as follows:

    WITH SubQuery1 AS
    (
    SELECT 0 AS ProductLevel, Company, ParentJob AS FinishedJob, ParentJob, AssemblySeq, ProdQty, QtyCompleted, ParentPart, MtlSeq, ReqDate,...
  • Reply To: Create a View with Index

    This is my 1st view where I build up the data:

    SELECT        jh.Company, jh.JobNum AS ParentJob, jh.JobFirm, jh.JobReleased, ja.AssemblySeq, jh.PartNum AS...
  • Reply To: Create a View with Index

    Gotcha, my understanding of a cte was a recursive cte using UNOIN ALL.

  • Reply To: Create a View with Index

    Apologies - I'm not sure what you mean - there is no cte in the above SQL statement.

  • Reply To: Create a View with Index

    I am still using the cte - but the execution has reduced to 00:00:00 with 1635 records.

    But the cte adopts the OUTER APPLY that you advised earlier.

  • Reply To: Create a View with Index

    The above SQL executes in around 00:00:02 and returns 28,801 records.

    My overall cte report now executes quickly but I'm unsure of how to bring into this SQL Code additional aggregate...

  • Viewing 15 posts - 1 through 15 (of 32 total)