Select distinct column

Dear Sir,
My table columns are below
rolno,sub_code,exam_type,marks
datas are below
1 1 regular 50
1 1 supplementary 50
1 2 regular 70
1 3 regular 80
2 1 regular 50
2 2 regular 60
2 3 regular 70
2 4 regular 60
3 1 regular 50
3 1 supplementary 70
3 2 regular 60
3 3 regular 80
3 4 regular 60
my query needs to fetch like this if there is equal mark for same sub_code in regular and supplementary it should fetch the supplementary and all the student who have appear for the supplementary
1 1 regular 50
1 1 supplementary 50
1 2 regular 70
1 3 regular 80
3 1 supplementary 70
3 2 regular 60
3 3 regular 80
3 4 regular 60
Please help
regards
sanat kumar
thank you sir

user591475 wrote:
Dear Sir,
My table columns are below
rolno,sub_code,exam_type,marks
datas are below
1 1 regular 50
1 1 supplementary 50
1 2 regular 70
1 3 regular 80
2 1 regular 50
2 2 regular 60
2 3 regular 70
2 4 regular 60
3 1 regular 50
3 1 supplementary 70
3 2 regular 60
3 3 regular 80
3 4 regular 60
my query needs to fetch like this if there is equal mark for same sub_code in regular and supplementary it should fetch the supplementary and all the student who have appear for the supplementary
1 1 regular 50
1 1 supplementary 50
1 2 regular 70
1 3 regular 80
3 1 supplementary 70
3 2 regular 60
3 3 regular 80
3 4 regular 60It's not clear what you want. Why are you getting the details of rolno 3 showing, because the rules you describe aren't met.... the supplementary with mark 70 for sub code 1 does not have an equal regular mark of 70 for subcode 1 anywhere in the data.

Similar Messages

  • Select distinct for a date column in present. service when creating prompt

    hi all
    I am trying to create some new prompts in my answers and I have the following problem. When I try to create a new prompt on a date column ( for example Modification Date), when I try to run this report on this prompt it is displaying the same date a lot of times ( for example 2/4/11 it is being displayed 4 times).
    Is there any way i can change this, so to display distinct dates?
    Thank you and best regards

    Hi Deva
    I am trying to use this, but in the system are being saved the date + hour.
    When i try select distinct modification date from My_view, i still have the same dates because they have different hours.
    When i try select disctinct to_date(modification_date)..... I am having an error in BI.
    Please help me to solve this issue.
    Regards

  • Select DISTINCT attribute vlaues fom XMLTYPE column and...

    Hello
    I have spent whole day to find the solution with no success. PLEAS HELP !
    The Problem :
    1. I have table with xmlType column in this column is the following xml:
    <revision>
    <product id = 1>
    <screw>
    <img id = 1/>
    </screw>
    <screw>
    <img id = 2/>
    </screw>
    </product>
    <product id = 2>
    <screw>
    <img id = 1/>
    </screw>
    </product>
    </revision>
    I must select DISTINCT img IDs and then select/join them form relational table img (id(number), pic (blob) )
    I can't find the solution to select distinct attribute values from XML!
    I have tried this:
    select extract(c.xml, 'revision/product/screw/img[not(@id=preceding-sibling::img/@id)]/@id') from TABLE c;

    Hello Odie_63
    I have again problem finally my XML looks that:
    <revision>
    <product id = "1">
    <screw>
    <img id = "1"/>
    </screw>
    <component>
    <img id = "1"/>
    </component>
    <screw>
    <img id = "2"/>
    </screw>
    <component>
    <img id = "2"/>
    </component>
    </product>
    <product id = "2">
    <screw>
    <img id = "1"/>
    </screw>
    <component>
    <img id = "4"/>
    </component>
    </product>
    </revision>'));
    And I don't know why my following statement doesn't work. (I must slect all distinct id from <img>).
    select distinct x.img_id
    from cfg_xml t
    , xmltable(
    '/revision/definitions/product'
    passing T.EQ_CFG_XML
    columns img_id number path '/component/img/@id',
    img_id2 number path '/screw/img/@id'
    ) x
    And this is VERY SLOW :/
    select x.img_id, y.img_id
    from cfg_xml t
    , xmltable(
    '/revision/definitions/product/screw/img'
    passing T.EQ_CFG_XML
    columns img_id number path '@id'
    ) x,
    xmltable(
    '/revision/definitions/product/component/img'
    passing T.EQ_CFG_XML
    columns img_id number path '@id'
    ) y
    Is it possible to return al distinct ID in one column>?
    Thanks for HELP :)
    Edited by: kozand on 2011-06-29 07:50

  • Select distinct record based on column

    Hello All,
    I have a table that has more than one row as Detail for a single invoice number(screenshot below). When I create report based on this table, I get multiple rows for single invoice. I mean Invoice 000027 shows up with 5 different rows on the SSRS report.
    Is there a way I could display a single row for a single invoice? Any thoughts on this will be greatly appreciated. Thanks.
    Regards,
    Amol
    eport )

    Thank you all for your suggestions. The issue is how can I get single distinct columns after joining 2 tables (InvoiceHeader & InvoiceDetail). I am using following query in my dataset.
    SELECT DISTINCT I.recid, I.InvNumber, D.Detail, I.CompanyName, I.Addr1, I.SalesRep, I.JobNumber, I.Status, I.InvDate, I.TotalInvAmount
    FROM            InvoiceHeader AS I INNER JOIN
                             InvoiceDetails AS D ON I.InvNumber = D.InvoiceNumber
    WHERE        (I.InvNumber = @InvoiceNumber) AND (I.InvDate >= @StartDate) AND (I.InvDate <= @EndDate) AND (I.CompanyName IN (@Customer)) AND (I.Status IN (@Status)) OR
                             (I.InvDate >= @StartDate) AND (I.InvDate <= @EndDate) AND (I.CompanyName IN (@Customer)) AND (I.Status IN (@Status)) AND (I.JobNumber = @JobNo) OR
                             (I.InvNumber = @InvoiceNumber) AND (I.InvDate >= @StartDate) AND (I.InvDate <= @EndDate) AND (I.CompanyName IN (@Customer)) AND (I.Status IN (@Status)) 
                             AND (@JobNo = '') OR
                             (I.InvDate >= @StartDate) AND (I.InvDate <= @EndDate) AND (I.CompanyName IN (@Customer)) AND (I.Status IN (@Status)) AND (I.JobNumber = @JobNo) AND 
                             (@JobNo = '') OR
                             (I.InvDate >= @StartDate) AND (I.InvDate <= @EndDate) AND (I.CompanyName IN (@Customer)) AND (I.Status IN (@Status)) AND (@JobNo = '') AND 
                             (@InvoiceNumber = '')
    ORDER BY I.InvNumber DESC
    Thanks again.
    Amol

  • Select distinct('more than one column') from ....

    Why does this sql statement not work:
    select distinct(column_a, column_b, column_c), empno
    from emp;
    How can I 'select distinct' using more than one column.

    Actually, DISTINCT applies to all columns in the result.
    Distinct is not a function, you cannot do distinct(column1, column2, ...).
    As a matter of fact it doesn't make sense to expect distinct applies to only one column, because you do not specify any criteria on how to select the values for the second column.
    A final note: you can do distinct(column1), column2, but this will still apply to both columns!
    Here're some examples that will all return both rows from the set, where set is: (1,1), (1,2):
    select distinct val1, val2
    from
    select 1 as val1, 1 as val2 from dual
    union all
    select 1 as val1, 2 as val2 from dual
    select distinct val1||'-'||val2
    from
    select 1 as val1, 1 as val2 from dual
    union all
    select 1 as val1, 2 as val2 from dual
    select distinct(val1), val2 -- this is very misleading. distinct still applies to both columns
    from
    select 1 as val1, 1 as val2 from dual
    union all
    select 1 as val1, 2 as val2 from dual
    Edited by: user4010726 on Dec 1, 2009 11:06 AM
    Edited by: user4010726 on Dec 1, 2009 11:07 AM

  • Query help in select Distinct on one column.

    CREATE GLOBAL TEMPORARY TABLE Table1 (
    ID1 varchar2(100) ,
    Name1 varchar2(100),
    Name11 varchar2(100)
    insert into Table1 values ('a','n1','h3');
    insert into Table1 values('b','n2','h2');
    insert into Table1 values('a','n3','h1');
    insert into Table1 values('c','n4','h5');
    insert into Table1 values ('c','n5','h4');
    insert into Table1 values('d','n6','h6');
    select * from Table1;
    ID1,NAME1,     NAME11
    a,     n1,     h3
    b,     n2,     h2
    a,     n3,     h1
    c,     n4,     h5
    c,     n5,     h4
    d,     n6,     h6
    I am trying to select distinct ID1 and all values associated with it which is max row.I want to result as -
    ID1,NAME1,     NAME11
    a,     n3,     h1
    b,     n2,     h2
    c,     n5,     h4
    d,     n6,     h6
    Can you please help me to write simple query to get above result.
    Edited by: 871447 on Jul 25, 2011 9:42 AM
    Edited by: 871447 on Jul 25, 2011 9:45 AM

    Hi,
    Do a self-join, to combine the two rows for each value of id1 onto one output row.
    Make it an outer join, in case there is only one row with a vlaue for id1.
    SELECT  l.id1
    ,     l.name1
    ,     NVL ( r.name11
             , l.name11
             )          AS name11
    FROM              table1     l
    LEFT OUTER JOIN     table1     r  ON  l.id1     = r.id1
                              AND l.name1     < r.name1
    ;Edited by: Frank Kulash on Jul 25, 2011 12:57 PM
    Sorry, I mis-read the problem.
    Lee's solution, above, assumes that name1 is unique, as it is in your sample data.
    What output would you want if that's not the case?
    If name1 is not unique, but the combination of (id1, name1) is unique, then you can modify Lee's solution like this:
    SELECT  *
    FROM    table1
    WHERE   (id1, name1) IN (
                        SELECT    id1
                        ,       MAX (name1)
                               FROM          table1
                        GROUP BY  id1
    ;Or, if you can't make any assumptions about uniqueness, you might need something like this:
    WITH     got_r_num     AS
         SELECT  id1, name1, name11
         ,     ROW_NUMBER () OVER ( PARTITION BY  id1
                                   ORDER BY          name1     DESC
                             ,                name11     DESC
                           )      AS r_num
         FROM     table1
    SELECT  id1, name1, name11
    FROM     got_r_num
    WHERE     r_num     = 1
    ;

  • Select Distinct (More than one column)

    Hi All,
    I have the following SQL statement written in MySQL that returns only one row per MODCODE with the associated DEPTCODE of AE:
    SELECT DISTINCT
    EL_MODULE.DEPTCODE, EL_MODULE.MODCODE, EL_MODULE.MODNAME, EL_MODULE.MODLEVEL, EL_DEPTLEVEL.DEPTLEVELHEADER
    FROM EL_DEPTLEVEL, EL_MODULE
    WHERE EL_MODULE.MODLEVEL = EL_DEPTLEVEL.LEVELCODE AND EL_MODULE.DEPTCODE='AE' ORDER BY EL_MODULE.MODLEVEL
    However when I attempt to use this in oracle it returns three rows, could somebody point out what it is I need to change to get this working correctly in oracle.
    Hope someone can help.
    Jon

    Duplicates? No way! This query returns unique comibination of
    EL_MODULE.DEPTCODE,
    EL_MODULE.MODCODE,
    EL_MODULE.MODNAME,
    EL_MODULE.MODLEVEL and
    EL_DEPTLEVEL.DEPTLEVELHEADER
    Cheers
    Sarma.

  • Select sum(distinct column ) from ....

    Hello All,
    I have a table the contains ID and size.
    An ID identifies a unique object, but it can be repeated. The following is valid:
    ID Size
    1 3
    4 5
    5 3
    1 3
    What I am trynig to do is get the sum of all sizes in the table. I tried this query:
    select sum(distinct size) from table;
    But it does give the right result since different objects could have the same size. I tried
    select sum(size) group by ID;
    But it prints to me huge number of IDs and sums the sizes of an ID together. What I want thuogh is to look at the unique rows (without duplicates) and then sum their sizes together and get the result.
    Any help would be greatly appreciated.
    Thank you
    P.S.: Sorry, I am an absolute Oracle/SQl newbie.
    Thanks for your help in advance

    An ID identifies a unique object, but it can be repeated.Fnord.
    I think your data model could withstand some refactoring but what you need to do is:
    SELECT sum(size) FROM
      (  SELECT distinct id, size FROM your_table)
    /This of course assumes that your duplication is complete and you don't have duplicate IDs with different sizes.
    You still ought to check out the concept of UNIQUE constraints though. A database ain't a database without relational integrity.
    Cheers, APC

  • How to select distinct values from a table when it has composite primary ke

    Hi
    I have the requirement like , I need to select distinct one column values from the table which has composite primary key. How to acheive this functioinality using view object.
    Eg : Table 1 has col1 and col2, col3
    col1 col2 col3
    1 A NA
    1 B NA
    2 A NA
    3 C NA
    2 D NA
    primary key (col1,col2)
    I have to select distinct col1.
    Thanks

    Hi
    I got the solution for above. By Creating the read only view object we can acheive this.
    thanks

  • Select Distinct and join in ODI

    Hi,
    I have following task to perform: I am loading metadata into Planning dimension from Oracle database. I have two tables
    1. "Sales"
    Columns: Name, Number, Value
    Sample Data:
    Product 1, 10, 200
    Product 2, 30, 100,
    Product 1, 15, 500
    2. P&R
    Columns:
    Name, Alias
    Product 1, SampleSoda1
    Product 2, SampleSoda2,
    Resource 1, CanForSoda,
    Resource 2, CO2
    What I need to do is: I have to select name and alias from second table of all products that were sold.
    So I need to select distinct Name from Table 1, naxt join it with Table 2 (so I have Name and Alias) and load it to planning.
    I am a little confused how to do it.
    Any help would be great!
    Best regards,
    Greg

    Hi Greg,
    What you can do is either :
    - Create a yellow interface with your table Sales as source. Map the name column directly in the target. In the flow tab, click on your target and select "Distinct rows".
    - Create a second interface, with your first interface as source. Select the "Use Temporary Interface as Derived Table (Sub-Select)" checkbox.
    - Add your second datastore and join it. Or you can use a lookup table.
    OR
    - Create an interface with Sales and P&R as source (or set P&R as a lookup table).
    - Go on the flow tab and select "Distinct rows".
    If you've a lot a data in the first table, I would go for the first solution.
    Hope it helps.
    Regards,
    JeromeFr
    Edited by: JeromeFr on Feb 14, 2013 9:52 AM
    To be more clear in the first step of solution 1

  • ORDER BY using a Non-SELECT list column

    I need to SELECT DISTINCT values from a column and ORDER it by another column in the same table which is not in the SELECT list. When i got
    ORA-01791: not a SELECTed expression error, I tried various things like putting ORDER BY clause in the outer query, using a DISTINCT in the ORDER BY clause,..etc but couldn't succeed.
    SQL> create table sample_table (col1 number, col2 number);
    Table created.
    SQL> select distinct(col1)
      2  from sample_table
      3  order by col2;
    order by col2
    ERROR at line 3:
    ORA-01791: not a SELECTed expression
    SQL> select col1 from
      2  (select distinct(col1) col1 from sample_table)
      3  order by col2;
    order by col2
    ERROR at line 3:
    ORA-00904: "COL2": invalid identifier
    SQL> select distinct(col1) col1 from sample_table
      2  order by distinct(col2);
    order by distinct(col2)
    ERROR at line 2:
    ORA-00936: missing expressionAny workarounds for this seemingly simple requirement?

    Any workarounds for this seemingly simple requirement?This is not a simple requirement. It is a self contradictory requirement.
    You want to order an result on a attribute that you don't have. This is not possible from a logical point of view.
    Like saying,
    "I want the typical/distinct family size in houses in my town, ordered by house number."

  • Select distinct is using the wrong index

    Hello,
    I have an indexes question?
    I have a table with 1M rows, the table structure is as follows:
    create table X(aTime DATE , a1 NUMBER(28,0), a2 NUMBER(28,0), a3 NUMBER(28,0), .... , a20 NUMBER(28,0) );
    I have also 2 indexes:
    - IDX1 is defined on (aTime, a1, a2, a3).
    - IDX2 is defined on (a1, a2, a3).
    I run the following query: "SELECT DISTINCT A1, A2, A3 from X;" and see that the optimizer chooses to do a FTS (full table scan) though I was expecting him to use IDX2 because it looks like a "covering" indexes giving all the answers to the query without fetching data rows.
    When I try to force him to use indexes, using the following hint "/*+INDEX(X IDX2)*/" the optimizer chooses IDX1.
    When I use same hint after I dropped IDX1 the optimizer still prefers to make FTS .
    Some general info:
    - a1, a2 and a3 have about 500 distinct values each).
    - db version 8.1.7.4.
    - all tables and indexes are analyzed.
    I have two questions:
    ===============
    1.
    Why does the optimizer prefers IDX1 (aTime, a1, a2, a3) over IDX2 (a1, a2, a3) when the query specifically requests distinct values of (aTime, a1, a2, a3), isn't there a shortcut the optimizer should use here?
    2.
    When I request the optimizer to use specific index (using hints), shouldn't it use the index I request regardless of his calculations? If not, is there any way to change this behavior?
    Tal Olier
    [email protected]

    You said you analyzed the tables and indexes. Did you also analyze the indexed columns?
    A full table scan may be a better execution plan than using an index, especially if you are selecting the full table.
    Remember that a hint is jut that, a hint. It suggests to the optimizer to do something, but the optimizer may still choose a different plan.

  • Selecting fewer columns from cached results

    If I'm reading the docs right, I should be able to create a request with X number of columns to populate the cache, so that a subsequent request that has a direct subset of those columns would hit the cache. That's not what I'm seeing.
    I have four fact columns in the RPD. The first three, Sales, Cost, and Units, are coming straight from the Physical Layer. The fourth, Profit, is a subtraction of Sales minus Cost.
    Here's what I'm seeing:
    1a. Log In to Answers
    1b. Create Query: Year, Sales, Cost, Profit - this populates the cache.
    1c. Log Out of Answers
    1d. Log back in to Answers
    1e. Create Query: Year, Sales, Cost - this query does NOT hit that cache entry.
    2a. Close all cursors (under Administration...Manage Sessions)
    2b. Log Out
    2c. Purge Cache
    3a. Log In to Answers
    3b. Create Query: Year, Sales, Cost, Units - this populates the cache.
    3c. Log Out of Answers
    3d. Log back in to Answers
    3e Create Query: Year, Sales Cost - this query DOES hit the cache entry.
    The only difference between the two sequences is that one references a calculated column (Profit) and the other does not.
    Incidentally, I've tested this with Profit defined first as a subtraction of the logical columns, and then again as a subtraction of the physical columns, with the same behavior observed both ways.
    Can someone please confirm this behavior and suggest a reason why it should occur?

    Turribeach, here are the Session Logs for each of the four requests. I've interspersed the steps between double-rows of = signs.
    ===================================================
    ===================================================
    STEP 1A: Log In
    STEP 1B: Create request - Year, Sales, Cost, Profit
    ===================================================
    ===================================================
    +++Analyst:320000:320001:----2009/01/15 09:13:51
    -------------------- Logical Request (before navigation):
    RqList
    Times.Year as c1 GB,
    Sales:[DAggr(~Base Facts.Sales by [ Times.Year, Times.Year End Date] )] as c2 GB,
    Cost:[DAggr(~Base Facts.Cost by [ Times.Year, Times.Year End Date] )] as c3 GB,
    Sales:[DAggr(~Base Facts.Sales by [ Times.Year, Times.Year End Date] )] - Cost:[DAggr(~Base Facts.Cost by [ Times.Year, Times.Year End Date] )] as c4 GB,
    Times.Year End Date as c5 GB
    OrderBy: c5 asc
    +++Analyst:320000:320001:----2009/01/15 09:13:51
    -------------------- Sending query to database named BIEE_TRAIN (id: <<1690>>):
    WITH
    SAWITH0 AS (select sum(round(T68.COST , 2)) as c1,
    sum(round(T68.SALES , 2)) as c2,
    T61.YEAR as c3,
    T61.YEAR_END_DATE as c4
    from
    GLOBAL_ADMIN.BI_D_TIME T61,
    GLOBAL_ADMIN.BI_F_SALES T68
    where ( T61.MONTH = T68.MONTH )
    group by T61.YEAR, T61.YEAR_END_DATE)
    select distinct SAWITH0.c3 as c1,
    SAWITH0.c2 as c2,
    SAWITH0.c1 as c3,
    SAWITH0.c2 - SAWITH0.c1 as c4,
    SAWITH0.c4 as c5
    from
    SAWITH0
    order by c5
    +++Analyst:320000:320001:----2009/01/15 09:13:52
    -------------------- Query Result Cache: [59124] The query for user 'Analyst' was inserted into the query result cache. The filename is 'C:\OracleBIData\cache\NQS_TRAINING_733424_33231_00000000.TBL'.
    ===================================================
    ===================================================
    STEP 1C: LOG OUT
    STEP 1D: LOG IN
    STEP 1E: Create request - Year, Sales, Cost
    ===================================================
    ===================================================
    +++Analyst:330000:330001:----2009/01/15 09:17:41
    -------------------- Logical Request (before navigation):
    RqList
    Times.Year as c1 GB,
    Sales:[DAggr(~Base Facts.Sales by [ Times.Year, Times.Year End Date] )] as c2 GB,
    Cost:[DAggr(~Base Facts.Cost by [ Times.Year, Times.Year End Date] )] as c3 GB,
    Times.Year End Date as c4 GB
    OrderBy: c4 asc
    +++Analyst:330000:330001:----2009/01/15 09:17:41
    -------------------- Sending query to database named BIEE_TRAIN (id: <<2062>>):
    select T61.YEAR as c1,
    sum(round(T68.SALES , 2)) as c2,
    sum(round(T68.COST , 2)) as c3,
    T61.YEAR_END_DATE as c4
    from
    GLOBAL_ADMIN.BI_D_TIME T61,
    GLOBAL_ADMIN.BI_F_SALES T68
    where ( T61.MONTH = T68.MONTH )
    group by T61.YEAR, T61.YEAR_END_DATE
    order by c4
    +++Analyst:330000:330001:----2009/01/15 09:17:41
    -------------------- Query Result Cache: [59124] The query for user 'Analyst' was inserted into the query result cache. The filename is 'C:\OracleBIData\cache\NQS_TRAINING_733424_33461_00000001.TBL'.
    *** Note: At this point, there are indeed TWO entries in the cache. ***
    ===================================================
    ===================================================
    STEP 2A: Close all cursors
    STEP 2B: Log Out
    STEP 2C: Purge the cache
    STEP 3B: Create request - Year, Sales, Cost, Units
    ===================================================
    ===================================================
    +++Analyst:350000:350001:----2009/01/15 09:23:18
    -------------------- Logical Request (before navigation):
    RqList
    Times.Year as c1 GB,
    Sales:[DAggr(~Base Facts.Sales by [ Times.Year, Times.Year End Date] )] as c2 GB,
    Cost:[DAggr(~Base Facts.Cost by [ Times.Year, Times.Year End Date] )] as c3 GB,
    Units:[DAggr(~Base Facts.Units by [ Times.Year, Times.Year End Date] )] as c4 GB,
    Times.Year End Date as c5 GB
    OrderBy: c5 asc
    +++Analyst:350000:350001:----2009/01/15 09:23:18
    -------------------- Sending query to database named BIEE_TRAIN (id: <<2399>>):
    select T61.YEAR as c1,
    sum(round(T68.SALES , 2)) as c2,
    sum(round(T68.COST , 2)) as c3,
    sum(round(T68.UNITS , 0)) as c4,
    T61.YEAR_END_DATE as c5
    from
    GLOBAL_ADMIN.BI_D_TIME T61,
    GLOBAL_ADMIN.BI_F_SALES T68
    where ( T61.MONTH = T68.MONTH )
    group by T61.YEAR, T61.YEAR_END_DATE
    order by c5
    +++Analyst:350000:350001:----2009/01/15 09:23:19
    -------------------- Query Result Cache: [59124] The query for user 'Analyst' was inserted into the query result cache. The filename is 'C:\OracleBIData\cache\NQS_TRAINING_733424_33798_00000002.TBL'.
    ===================================================
    ===================================================
    STEP 3C: LOG OUT
    STEP 3D: LOG IN
    STEP 3E: Create request - Year, Sales, Cost
    ===================================================
    ===================================================
    +++Analyst:360000:360001:----2009/01/15 09:24:36
    -------------------- Logical Request (before navigation):
    RqList
    Times.Year as c1 GB,
    Sales:[DAggr(~Base Facts.Sales by [ Times.Year, Times.Year End Date] )] as c2 GB,
    Cost:[DAggr(~Base Facts.Cost by [ Times.Year, Times.Year End Date] )] as c3 GB,
    Times.Year End Date as c4 GB
    OrderBy: c4 asc
    +++Analyst:360000:360001:----2009/01/15 09:24:36
    -------------------- Cache Hit on query:
    Matching Query:     SET VARIABLE QUERY_SRC_CD='Report';SELECT "Time Dimension"."Year" saw_0, "Base Measures".Sales saw_1, "Base Measures".Cost saw_2, "Base Measures".Units saw_3 FROM Global ORDER BY saw_0
    Created by:     Analyst
    +++Analyst:360000:360001:----2009/01/15 09:24:36
    -------------------- Query Status: Successful Completion
    +++Analyst:360000:360001:----2009/01/15 09:24:36
    *** Note: At this point, there is ONE entry in the cache. ***

  • Count a distinct column value in an interactive report

    Hi,
    I'm struggling with this and would appreciate any pointers.
    I have built a view here:
    http://apex.oracle.com/pls/otn/f?p=11189:1
    The report can have duplicate column values. I'm tying to find a way using the interactive report functionality (i.e. without modifying the underlying SQL) to count a distinct column value. For example, in the example following the link I'd like to be able to count the unique customer_ids and return 7.
    This may be fundametally impossible depending on the way the SQL is generated for the interactive reports. If this is the case can anyone confirm this?
    Many thanks
    Yog.

    <B>"Not modifying views is fair enough. But not wrapping a SELECT around them? Really? Why? And as I said, that's imposible, the IR already does it."</B>
    This is not a problem. However for the IR's it's a development decision to keep all reported columns ( and analysis on these columns ) as a seperate development process to be controlled centrally by a seperate team. The point to remember is that the app looks at hundereds of views and it was decided that modifying each report to fit each instance would become cumbersome to manage and to put it simply there are not the resources to do it.
    again, I'm not here to justify any of that!
    <B>SELECT *" ? Every single time? Even when you want to populate a LOV with some names</B>
    No just the Reports. It is a very very simple app; a big list an a page for each report.
    <B>"I think you should always ask what you want, not less, not more"</B>
    I agree, and that should include select * from view.
    <B>"Why fetch data you don't want to see"</B>
    Some users will want to see some data from the view and other users will want to see other data, Over the whole user base someone somewhere will want to see all of it.
    <B> Actually, there is something good in this, in the future, when you will be asked to check and try to improve the load time of some page, here is the first place where you should look</B>
    Brilliant! Like it!!
    <B>Does it by any chance fetch a bunch of 20 meg LOBS and then discards them</B>
    No, Thankfully a few varchar2 columns and a lot of numeric columns, nothing huge. The reports are acutally pretty fast at the moment...

  • SELECT DISTINCT With OPEN cursor FOR

    Hello.
    I have the following procedure. All it does is open a cursor for an SQL string passed into it, and return the open cursor.
    PROCEDURE sp_execute_dynamic (hold_input_string IN CLOB,
    hold_cursor OUT hold_cursor_type) IS
    BEGIN
    OPEN hold_cursor FOR TO_CHAR(hold_input_string);
    END sp_execute_dynamic;
    It works fine except when I perform SELECT DISTINCT. I get the following error.
    SQL> declare
    2 TYPE hold_cursor_type IS REF CURSOR;
    3 hold_cursor hold_cursor_type;
    4 hold_object_name VARCHAR2(1024);
    5 hold_object_type VARCHAR2(1024);
    6 begin
    7 dynamic_sql_pkg.sp_execute_dynamic('select distinct object_name from user_objects where object_
    name in (''PLAN_TABLE'',''DBA_OBJECTS'')',hold_cursor);
    8 loop
    9 fetch hold_cursor into hold_object_name, hold_object_type;
    10 exit when hold_cursor%NOTFOUND;
    11 dbms_output.put_line('Object Name = '||hold_object_name||' Object Type = '||hold_object_type);
    12 end loop;
    13 end;
    14 /
    declare
    ERROR at line 1:
    ORA-01007: variable not in select list
    ORA-06512: at line 9
    It does the same thing with SELECT UNIQUE or SELECT with a GROUP BY. Can anyone tell me why this happens and what I could to to work around it?
    Thanks
    Chris

    see at line 7 you are selecting only one column and at line 9you are fetching into two variables
    7 dynamic_sql_pkg.sp_execute_dynamic('select distinct object_name from user_objects where object_
    name in (''PLAN_TABLE'',''DBA_OBJECTS'')',hold_cursor);
    8 loop
    9 fetch hold_cursor into hold_object_name, hold_object_type;
    HTH

Maybe you are looking for

  • Midi Delay when Using Rewire?

    I am experiencing really bad midi delay when using LE7.1 & Reason 3.0 in Rewire mode. Should this be happenening? I take it that I am setup properly for rewire or I would not hear anything at all. I can trigger Reason synths via LE in rewire mode but

  • Pass parameter to report paramater form from a form

    I defined parameter in a form. I am trying to pass the parameters to a report's parameter form. Is there any way to accomplish this? Thank you!

  • Help..Directory move..lost files?

    Hi All, Major problem.  I have saved raw files from the camera to a folder Photos on my C Drive, in subfolders per date i.e. 2007-01-01 etc.  I imported from each folder into LR (now 2.5) so that there is a folder for each date with the assorted meta

  • HT201210 where is my backup

    where can i found my backup because the system said that i need to delete my backup and try againg the update

  • Can't Use UPK with Cognos Reports

    I am trying to use UPK to record Cognos reports. If I have UPK open, the Cognos report freezes and will not run, so I'm unable to use UPK to record these reports. I have tried logging on as a remote user, or opening the report without UPK open, then