Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 376195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T14:34:32+00:00 2026-05-12T14:34:32+00:00

The following query ( V_TITRATION_RESULTS ) is a view uses a row-to-column pivot which

  • 0

The following query (V_TITRATION_RESULTS) is a view uses a row-to-column pivot which returns about 20,000 rows:

SELECT test.created_on as "Created On", 
       r_titr as "Titrator", 
       r_fact as "Factor" 
  FROM (SELECT test_id, 
               MAX(CASE WHEN result_tmpl_id = 2484 THEN result END) r_titr, 
               MAX(CASE WHEN result_tmpl_id = 2483 THEN result END) r_fact 
          FROM (SELECT lims.test.* 
                  FROM lims.test 
                 WHERE test_tmpl_id = 867) 
          JOIN lims.result USING (test_id) 
      GROUP BY test_id) 
  JOIN lims.test test USING (test_id)

I would like to search on the view returning only the tests since the beginning of September:

SELECT * FROM V_TITRATION_RESULTS WHERE "Created On" > DATE '2009-09-01'

The ‘GET PLANs’ for both the view and filtered query are identical, and the trace statistics (below) for both queries are similar indicating the rows aren’t filtered until they all have been processed.

                   VIEW     Filtered      Diff
Physical Reads    81730        83946      2216
Logical Reads    364488       344063    -20425
Sort Rows        632194       632193        -1
ROWID Gets       580778       580778         0
Chained Gets     101823       101823         0
Memory (kB)         307          324        17
Scan Rows             3            3         0
Scan Gets             3            3         0
Sorts In Mem          4            4         0
Temp Segments         1            1         0
Scan Short            3            3         0
CPU Total (sec)    8.13          7.3     -0.83
First Row        2m 12s       2m 40s    
Last Row            18s           0s    

How can I rewrite my view so that a WHERE condition will filter the tests before the row-to-column pivot?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T14:34:32+00:00Added an answer on May 12, 2026 at 2:34 pm

    Steven, I’m wondering why you can’t use:

    CREATE OR REPLACE VIEW V_TITRATION_RESULTS AS 
      SELECT lt.test_id, 
             lt.created_on,
             MAX(CASE WHEN result_tmpl_id = 2484 THEN result END) 'titrator', 
             MAX(CASE WHEN result_tmpl_id = 2483 THEN result END) 'factor'
        FROM lims.test lt 
        JOIN lims.result USING (test_id) 
       WHERE lt.test_tmpl_id = 867 
    GROUP BY lt.test_id, lt.created_on
    

    Getting rid of the subselects will improve query performance. Assuming Oracle 9i+ – mind that you can use Subquery Factoring (WITH clause) in views.

    Then you could use:

    SELECT vtr.* 
      FROM V_TITRATION_RESULTS vtr
     WHERE vtr.created_on > TO_DATE('2009-09-01', 'YYYY-MM-DD')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following query: view.reduce.group_level(5).keys which returns: [[1f9c79a33f399a7937d880c5f31e8dbc, 2011, 12, 29, 13], [1f9c79a33f399a7937d880c5f31e8dbc,
The following query uses an index seek on an index on the LastModifiedTime column.
I have the following query which is inside a loop and is breaking SELECT
The following query is taking more than 25 seconds to complete: SELECT c.* ,
The following query: select unnest(Table2.L) as X, unnest(Table1.O) from Table1, Table2 where Table1.code =
The following query returns the total amount of orders, per week, for the past
The following query: SELECT DISTINCT ClassName FROM SiteTree ORDER BY ClassName is returning things
I'm running the following query: SELECT * FROM all_tab_cols c LEFT JOIN all_varrays v
I have following query on a MySQL DB: SELECT * , r.id, x.real_name AS
I'm having some problems with the following Query: SELECT v.idnum ,v.full_name ,convert(varbinary(max),s.signature) as Sig

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.