Sql join query join

Hi I have 3 tables.
Table                   columns
1. Buy                     buyer,sellername
2. IM                      product,hdate,UOM,dept,sec,subsec
3. stud                    dept,sec,subsecRequired O/P with columns as :
buyer   product   dept  sec  subsec
---------------------------------------------------so please send me the join query for this.
Thank you.

I am getting the output with the above mentioned query as
buyer   product  dept    class     subsecs
90      glass    203     310      234
120     glass    203     310      234
354     glass    203     310      234
435     belts    330     243      890
435     belts    330     243      890
...like this I am getting the result...
So please help me in this issue..
Thank you.

Similar Messages

  • Help with Inner Join query in SQL

    Hope someone can help with this, as this is quite an involved project for me, and I'm just about there with it.
    My table structure is :
    table_packages
    packageID
    package
    packageDetails
    etc
    table_destinations
    destinationID
    destination
    destinationDetails
    etc
    table_packagedestinations
    packageID
    destinationID
    ..so nothing that complicated.
    So the idea is that I can have a package details page which shows the details of the package, along any destinations linked to that package via the packagedestinations table.
    So this is the last part really - to get the page to display the destinations, but I'm missing something along the way....
    This is the PHP from the header, including my INNER JOIN query....
    PHP Code:
    <?php
    $ParampackageID_WADApackages = "-1";
    if (isset($_GET['packageID'])) {
      $ParampackageID_WADApackages = (get_magic_quotes_gpc()) ? $_GET['packageID'] : addslashes($_GET['packageID']);
    $ParamSessionpackageID_WADApackages = "-1";
    if (isset($_SESSION['WADA_Insert_packages'])) {
      $ParamSessionpackageID_WADApackages = (get_magic_quotes_gpc()) ? $_SESSION['WADA_Insert_packages'] : addslashes($_SESSION['WADA_Insert_packages']);
    $ParampackageID2_WADApackages = "-1";
    if (isset($_GET['packageID'])) {
      $ParampackageID2_WADApackages = (get_magic_quotes_gpc()) ? $_GET['packageID'] : addslashes($_GET['packageID']);
    mysql_select_db($database_connPackages, $connPackages);
    $query_WADApackages = sprintf("SELECT packageID, package, costperpax, duration, baselocation, category, dateadded, agerange, hotel, educational_tours, field_trips, corporate_outings, plant_visits, budget_package, rollingtours, teambuilding, description, offer FROM packages WHERE packageID = %s OR ( -1= %s AND packageID= %s)", GetSQLValueString($ParampackageID_WADApackages, "int"),GetSQLValueString($ParampackageID2_WADApackages, "int"),GetSQLValueString($ParamSessionpackageID_WADApackages, "int"));
    $WADApackages = mysql_query($query_WADApackages, $connPackages) or die(mysql_error());
    $row_WADApackages = mysql_fetch_assoc($WADApackages);
    $totalRows_WADApackages = mysql_num_rows($WADApackages);
    $colname_educationalDestinations = "1";
    if (isset($_GET['PackageID'])) {
      $colname_educationalDestinations = (get_magic_quotes_gpc()) ? packageID : addslashes(packageID);
    mysql_select_db($database_connPackages, $connPackages);
    $query_educationalDestinations = sprintf("SELECT * FROM destinations INNER JOIN (packages INNER JOIN packagedestinations ON packages.packageID = packagedestinations.packageID) ON destinations.destinationID = packagedestinations.destinationID WHERE packages.packageID = %s ORDER BY destination ASC", GetSQLValueString($colname_educationalDestinations, "int"));
    $educationalDestinations = mysql_query($query_educationalDestinations, $connPackages) or die(mysql_error());
    $row_educationalDestinations = mysql_fetch_assoc($educationalDestinations);
    $totalRows_educationalDestinations = mysql_num_rows($educationalDestinations);
    ?>
    And where I'm trying to display the destinations themselves, I have : 
    <table>
            <tr>
                     <td>Destinations :</td>
                </tr>
               <?php do { ?>
            <tr>
                 <td><?php echo $row_educationalDestinations['destination']; ?></td>
            </tr>
            <?php } while ($row_educationalDestinations = mysql_fetch_assoc($educationalDestinations)); ?>
    </table>
    If anyone could have a quick look and help me out that would be much appreciated - not sure if its my SQL at the top, or the PHP in the page, but either way it would be good to get it working. 
    Thanks.

    First off, you need to get the database tables so that there is a relationship between them.
    In fact, if there is a one to one relationship, then it may be better to store all of your information in one table such as
    table_packages
    packageID
    package
    packageDetails
    destination
    destinationDetails
    etc
    If there is a one to many relationship, then the following would be true
    packages
    packageID
    package
    packageDetails
    etc
    destinations
    destinationID
    packageID
    destination
    destinationDetails
    etc
    The above assumes that there are many destinations to one package with the relationship coloured orange.
    Once you have the above correct you can apply your query as follows
    SELECT *
    FROM packages
    INNER JOIN destinations
    ON packages.packageID = destinations.packageID
    WHERE packages.packageID = %s
    ORDER BY destination ASC
    The above query will show all packages with relevant destinations

  • How to get Hierarchical XML File from a Database Join Query !

    Hi,
    How can i get a Hierarchical XML File from a Database Join Query ?
    Any join query returns repeated values as below:
    BD17:SQL>select d.dname, e.ename, e.sal
    2 from dept d
    3 natural join
    4 emp e
    5 /
    DNAME ENAME SAL
    ACCOUNTING CLARK 2450
    ACCOUNTING KING 5000
    ACCOUNTING MILLER 1300
    RESEARCH SMITH 800
    RESEARCH ADAMS 1100
    RESEARCH FORD 3000
    RESEARCH SCOTT 3000
    RESEARCH JONES 2975
    SALES ALLEN 1600
    SALES BLAKE 2850
    SALES MARTIN 1250
    SALES JAMES 950
    SALES TURNER 1500
    SALES WARD 1250
    14 rows selected.
    We tried use DBMS_XMLQUERY to generate a xml file, but it was unable to get xml in Hierarchical format.
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    - <ROWSET>
    - <ROW num="1">
    <DNAME>ACCOUNTING</DNAME>
    <ENAME>CLARK</ENAME>
    <SAL>2450</SAL>
    </ROW>
    - <ROW num="2">
    <DNAME>ACCOUNTING</DNAME>
    <ENAME>KING</ENAME>
    <SAL>5000</SAL>
    </ROW>
    - <ROW num="3">
    <DNAME>ACCOUNTING</DNAME>
    <ENAME>MILLER</ENAME>
    <SAL>1300</SAL>
    </ROW>
    - <ROW num="4">
    <DNAME>RESEARCH</DNAME>
    <ENAME>SMITH</ENAME>
    <SAL>800</SAL>
    </ROW>
    - <ROW num="5">
    <DNAME>RESEARCH</DNAME>
    <ENAME>ADAMS</ENAME>
    <SAL>1100</SAL>
    </ROW>
    - <ROW num="6">
    <DNAME>RESEARCH</DNAME>
    <ENAME>FORD</ENAME>
    <SAL>3000</SAL>
    </ROW>
    - <ROW num="7">
    <DNAME>RESEARCH</DNAME>
    <ENAME>SCOTT</ENAME>
    <SAL>3000</SAL>
    </ROW>
    - <ROW num="8">
    <DNAME>RESEARCH</DNAME>
    <ENAME>JONES</ENAME>
    <SAL>2975</SAL>
    </ROW>
    - <ROW num="9">
    <DNAME>SALES</DNAME>
    <ENAME>ALLEN</ENAME>
    <SAL>1600</SAL>
    </ROW>
    - <ROW num="10">
    <DNAME>SALES</DNAME>
    <ENAME>BLAKE</ENAME>
    <SAL>2850</SAL>
    </ROW>
    - <ROW num="11">
    <DNAME>SALES</DNAME>
    <ENAME>MARTIN</ENAME>
    <SAL>1250</SAL>
    </ROW>
    - <ROW num="12">
    <DNAME>SALES</DNAME>
    <ENAME>JAMES</ENAME>
    <SAL>950</SAL>
    </ROW>
    - <ROW num="13">
    <DNAME>SALES</DNAME>
    <ENAME>TURNER</ENAME>
    <SAL>1500</SAL>
    </ROW>
    - <ROW num="14">
    <DNAME>SALES</DNAME>
    <ENAME>WARD</ENAME>
    <SAL>1250</SAL>
    </ROW>
    </ROWSET>
    Thank you for some help.
    Nelson Alberti

    Hi,
    I wrote a general ABAP program which can be configured to grab contrent from an URL and post that content as a new PI message into the integration adapter .... from that point on normal PI configuration can be used to route it to anywhere ...
    It can be easily scheduled as a background job to grab content on a daily basis etc ...
    Regards,
    Steven

  • Deciphering column names in a join query using jdbc

    hi all....
    I am making a database adapter for a generic report generater. This adapter would be forming queries involing various tables. There are two ways of doing it . I fire an sql on parent table to get the keys and then go to child table for each one of them or i form a join query to get desired result.
    i want to go with the later approach where my query would be forming a join. The problem comes when table involved in this join has columns with the same name. for eg if a column "NOTE" is there in table A as well as table B on which i have a join. Resultset returns me with two "NOTE" columns and i cannot recognize which one belongs to which table.
    all API calls including getString("Note") seems to be referring to the first occurence of "Note" column.
    Also getTableName() and getSchemaName() APIs on resultsetMetadata doesnt return in anything in case of joins.
    Any pointers would be most appreciated.
    cheers
    vivek

    thanks for suggesting this solution ... though i had thought of the same onece .... unfortunately i cannot implement something like this coz out of the result set i have to instantiate an object hierarchy depending on the schema ....
    this also puts me in a doubt whether i can use join in my case.
    for eg ... .
    lets say we have a customer talbe and and address table which has one to many relationship .... one contact can have multiple addresses.
    Assuming a contanct "Joe Bloggs" having 3 addresses ...a query like following
    select contact.firstname contactfirstname , address.streetname addressstreetname from contact , address where contact.contactid = address.contactid
    this would return me 3 rows and i can also recognize various columns with their aliases ..
    but i would lose an important fact that i have to create one java object for contact class and 3 instances for addresses which i have to return finally.
    this means that i would like to return an object hierarchy with one contact object and 3 address object underneath it linked with contactid.
    Any other suggestions after reading the complete requirement are most welcome ...sorry for not puting the entire thing at first.
    i guess the only soln left is to visit contact and address table separately. :(

  • Problem getting results with no unique key in a joined query

    I created a descriptor to do a joined query, which generated a query in log as:
    Select t0.empID,t1.empID, t1.phone from Emp t0, Phone t1
    where t0.empId=t1.empId and t0.empId=1001
    When I run it, I got the result as:
    1001,1001,9999999
    1001,1001,9999999
    The correct result should be (I copy and paste the query from log into SQL-Plus):
    1001,1001,9999999
    1001,1001,1234455
    I suspect this is caused by Toplink caching objects by primary key. I wonder if anybody has a solution for this.
    My descriptor is created using WorkBench. Emp is the primary table, Phone as additional table linked by foreignKey empId.
    The join is implemented by modifying the descriptor as the following:
    ExpressionBuilder builder = new ExpressionBuilder();
    descriptor.getQueryManage()
    .setMultipleTableJoinExpression(
    builder.getField("EMP.EMPID").equal(
    builder.getField("EMP.EMPID")));
    descriptor.disableCacheHits();
    I'd really appreciate your help.

    I am implementing a people search function. The batch reading is quite expensive if toplink does a read query for every person. A customized query requires only one database access, the other way may requires hundreds.
    I don't want to use the cache either in this case because the database is also accessed by legacy system which cann't notify toplink any updates.
    I opened a TAR on this and the solution I got is to use ReportQuery rathen than ReadAllQuery. The only problem here is that now I have to map the query result to my class manually.

  • Filter on "---" in Left Outer Join Query

    Hi guys,
    very basic question but I have not found an answer, yet. I built an left outer join MDO query and need to select all those dataset that did not find a "partner", that is fields are set to "---". However, I do not manage to filter on '---', NULL...
    When using SQL, it appears to be a String "---" but in MDO???

    Hey guys, found out that IS NULL needs to be used in query. Anyway, it appears to cause problems somewhere else.
    I placed an IS NULL filter expression inside a join query but query did not return any results when called in by transaction. After removing this line, both NULL and NOT NULL data were returned. When used in test mode, IS NULL was working fine...

  • Cartesian Join query optimization

    Hello Experts!
    I have a question about cartesian join query which might look a bit weird.
    Assume the SQL query like that:
    SELECT DISTINCT A.NAME
    FROM A, B, C;
    Here we have cartesian join for 3 tables A, B and C.
    It looks to me, in order to get the result for such a particular SQL tables/sets B and C need to be accessed only to ensure they return at least 1 row (otherwise result set is empty), query table A, but there is no actual need to join the data.
    If you run such a query Oracle is doing full table scans and actually joins the data.
    Yes, DBMS is doing exactly what you are asking for, but I wonder if there is any way (SQL hint or db parameter or anything else) to enforce more optimal access path here?
    Obvious solution to remove B and C tables from the SELECT statement is not acceptable. :-)
    Thank you!

    Your statement in the other thread indicates you don't understand how the BI prompts actually work because you say you want it to do something that doesn't make sense for it to do.
    Of course Product and Account levels will be constrained to the interval you specified. It wouldn't make sense for them not to be. Because that would mean returning data for based on product and account levels that has a different open data range than what you specified.
    All UI prompt dialogs I have seen use AND relationships between the parameters. If there are three parameters (A, B, C) then the ultimate relationship is 'A AND B AND C'; not 'A OR (B AND C)', 'A AND (B OR C)', 'A OR (B OR C).
    Unless the tool allows you to select OR relationships you need to use a separate dialog box (parameter dialog) for each condition set.:-)
    I understand how BI prompts work and basically agree on your comment, but there are two problems here:
    1. I need to convince the customer his original requirements are not valid. Customer want it to work different way and there are some reasons why.
    2. There are pretty large dimensions and fact tables used here, so when I choose filter criteria for the Product (which is small table) to populate/recalculate prompt values, large SR dimension and fact tables are joined too, and if there are Account dimension filters added, huge Account dimension will be added as well. This looks to be a bit sub-optimal for just populating the Product prompt values.
    Of course, technically this is solvable, but requires to put some extra effort and does not solve the 1st issue.
    That other link doesn't explain the sample code you posted in this thread. Post the actual query that is being generated and the query that you want to actually use.This is what is generated:
    >
    select distinct T311691.X_CUST_SUBTYPE as c1
    from
    WC_LOV_SR_AREA_H T311695,
    WC_LOV_PROD_H T311687,
    WC_LOV_CUST_TYPE_H T311691,
    W_SRVREQ_D T302384 /* Dim_W_SRVREQ_D */
    where ( T311687.LEV1 = 'Product X' and T311691.X_CUST_TYPE = 'Business' and T302384.OPEN_DT between TO_DATE('2012-03-01 00:00:00' , 'YYYY-MM-DD HH24:MI:SS') and TO_DATE('2012-03-31 00:00:00' , 'YYYY-MM-DD HH24:MI:SS') )
    order by c1
    >
    This is what is actually needed to query this data:
    >
    select distinct T311691.X_CUST_SUBTYPE as c1
    from
    WC_LOV_CUST_TYPE_H T311691
    where ( T311691.X_CUST_TYPE = 'Business' )
    order by c1

  • Query/join problem

    Does anyone see any issues in my query/join?
    Select c.case_id, a.business_unit, a.field_name, a.change_date, a.old_value, a.new_value, a.created_by, a.creation_date, c.provider_group_id, c.creation_date, c.closed_dttm
    From ps_case c, ps_case_history_audit a
    where
    a.case_id = c.case_id and
    a.field_name = 'case_status' and
    a.new_value = 'Open - Dispatch' and
    a.created_by like '%tag%' and
    c.provider_group_id like '%tag%' and
    c.closed_dttm between '03-NOV-2013' and '10-NOV-2013'
    SQL Dev: All Rows Fetched: 0   But it should be returning something with the stated parameters.

    Hi,
    I'm willing to share what I know about SQL to help solve this problem.  Are you willing to share what you know about the data and the application?
    Whenever you have a question, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all the tables involved, and the results you expect from that data.
    Explain, using specific examples, how you get those results from that data.
    Always say what version of Oracle you're using (e.g. 11.2.0.2.0).
    See the forum FAQ: https://forums.oracle.com/message/9362002
    "0 rows found" is sometimes the correct answer.  Why do you think it's not in this case?
    If c.closed_dttm is a DATE (or a TIMESTAMP) then you shouldn't be comparing it to strings, as in
    c.closed_dttm between '03-NOV-2013' and '10-NOV-2013'
    However, that would probably produce too many rows in this case, not too few.
    At any rate, compare DATEs to other DATEs, for example
    c.closed_dttm between TO_DATE ('03-NOV-2013', 'DD-MON-YYYY') and ...
    If this isn't the cause of today's problem today, it will be tomorrow's.

  • On outer Join Query

    Hi All,
    I have a outer join query which is creating bottlenecks and increasing the cost of the query, the plan of the query is pretty awkward with multiple nested outer loop joins. Though its the requirement for me to write such a query. I would like to get advice from the SQL community to know whether we can rewrite the query in any other way so that it reduces the cost and there is considerable improvement in the plan.
    For example can we rewrite this query to ensure we get the same output with much improved plan and cost.
    Basically i want to avoid thsi left Outer Join. Can we do this any way with lesser cost and consistent gets.
    Here is a sample query.
    Select e.Empno,e.Ename,e.Sal, D.Dname,D.deptno
    From
    Emp e, Dept d
    Where e.Deptno(+) = d.Deptno
    Thanks in advance

    You haven't given us much to work with, not even your Oracle version. So, start with these:
    When your query takes too long
    When your query takes too long ...
    How to Post a SQL statement tuning request
    HOW TO: Post a SQL statement tuning request - template posting

  • Join query with cfoutput group

    Hi,
    I have the problem with join query and output the goup by, can anyone helps please?
    1: worked fine
    <cfquery name="qOrgs" datasource="#GetDSN()#">
    select org
    from cat
    </cfquery>
    <cfoutput query="qOrgs" group="org">
    #org#<br />
    </cfoutput>
    2: not work, not grouping and display duplicated.
    <cfquery name="qOrgs" datasource="#GetDSN()#">
    select org
      from user u
      inner JOIN cat c
      on u.userid= c.userid
    </cfquery>
    <cfoutput query="qOrgs" group="org">
    #org#<br />
    </cfoutput>
    Thanks

    To expand on Dan's answer;
    The "group" property of the <cfoutput...> tag is fairly simplistic.  All it actuall does is conditionally output content whenever the value of the specified group column changes.
    So if you do not use an ORDER BY clause in your SQL to group the values of that column together (or they don't naturally group because of the current state of the data in the database) then the output is probably not going to be as desired.

  • Complex query/join question

    Not sure if this goes here, but I thought I'd try anyway.
    I'm using Oracle 8i for a legacy app and the RDBMS won't be updated anytime soon. I'm trying to write a fairly complex sum and join query. I have two different tables with hours worked type information. I need to be able to sum the hours for a work day on each table and put, in a web table like a GridView, all rows, even if there isn't a match in the opposite table. So, for example
    Table 1
    ID SHOP WORKDATE SHOPHOURS
    1 AM1 1/1/2008 4
    1 AM1 1/1/2008 4
    2 AM1 1/1/2008 8
    3 AM1 1/1/2008 8
    Table 2
    ID WORKDATE PAYHOURS
    2 1/1/2008 7
    3 1/1/2008 8
    4 1/1/2008 9
    What I need to see is
    ID SHOP WORKDATE SHOPHOURS PAYHOURS
    1 AM1 1/1/2008 8 0
    2 AM1 1/1/2008 8 7
    3 AM1 1/1/2008 8 8
    4 1/1/2008 8 9
    Since i'm on 8i, I can't use a FULL OUTER Join, so i'm kind of stumped. Any suggestions would be greatly appreciated.

    You might want to post this to question to [SQL Forum|http://forums.oracle.com/forums/forum.jspa?forumID=75] instead for better result, but i can give you a solution. This is definitely not the best solution, but it works.
    select nvl(table1.id,table2.id) id, shop,
      nvl(table1.workdate,table2.workdate) workdate,
      sum(nvl(shophours,0)) shophours, sum(nvl(payhours,0)) payhours
    from table1, table2 where table1.id(+) = table2.id
    group by nvl(table1.id,table2.id), shop,
          nvl(table1.workdate,table2.workdate)
    union
    select nvl(table1.id,table2.id) id, shop,
      nvl(table1.workdate,table2.workdate) workdate,
      sum(nvl(shophours,0)) shophours, sum(nvl(payhours,0)) payhours
    from table1, table2 where table1.id = table2.id(+)
    group by nvl(table1.id,table2.id), shop,
          nvl(table1.workdate,table2.workdate) Cheers,
    [Nur Hidayat|http://nur-hidayat.net]

  • Join Query in Object Oriented Programming

    Hi,
    I am trying to understand better how OO programming should work in CFC context.  For example, I have two database tables: Customer and Order.  So I create two CFCs, one for Customer and another for Order.  In the CFCs I have query functions (select, insert, update) to access and manipulate data in the underlying tables.
    Now, I need to create a new CFC, OrderReport.  This CFC takes in customerID and returns data pulled from both Customer and Order tables.  I can just have a join query that pulls data from these two tables.  However, I have been wondering whether this method is within the spirit of Object Oriented programming.  Should this CFC be able to access directly to the two tables?  Or should I pull data separately using Customer CFC and Order CFC, and join them locally (ie. in OrderReport CFC)?  This latter method would be a lot slower to run than the first method.
    Can you advise me as to what the best practice is in the context of OO programming?  Thank you.

    This is a common question for those new to OO programming. Here are some of
    my thoughts on the topic.
    OO programming has nothing to do with tables. Your tables are essentially a
    relational storage of one part of a business concept. It just so happens
    that most of the data you need to support the business concept of Customer
    and the business concept of Order are stored in tables named Customer and
    Order. This is because database tables often relate to a business concept. I
    think you'd find that to get the entire customer, you'd have to get data
    from other tables, like State and Gender and other such tables.
    The reason why I bring this up is to begin to separate your thinking.
    Databases are concerned with efficient storage and retrieval of data.
    Objects (CFCs) are not concerned at all with storage of data. Objects are
    concerned with encapsulating business logic relating to a business concept.
    Just like your database may have columns not needed by your CFCs, your CFCs
    likely have methods not needed by your database.
    For example, if you wanted to know, in your application, whether to show an
    In Store Pickup option, you may wish to add an isLocal() method to your
    customer object. This would ( we'll pretend) get the customer's zip code,
    and look it up in  GeographicalPostalServiceMapper object to tell us how far
    away the customer is.
    The point is, the right OO (CFC) design has nothing to do with how your
    tables are organized in the database. You would do well to concern yourself
    with the needs of the application and what sort of questions you need your
    customer object to be able to answer to the other parts of your application.
    Like, isLocal(), isOver21(), isBadCreditRisk() and so on.
    As to your question about joins, you would do well to use joins in your
    application. Do not be afraid of using queries to get the information you
    need. Especially for reporting queries. In these cases, I often make an
    object called a xxxList. My CustomerList.cfc would have the different ways
    to list customer data, like CustomerOrders and CustomerOrderReturns. I'd
    hide this join relationship inside of the CustomerList object so only the
    CustomerList object has the SQL. That's usually enough encapsulation for the
    needs of my application.
    Truly, it doesn't matter what the name of the object is, just that you
    assign it the responsibility of managing a business concept and keep that
    business concept inside that object. You seem to have suggested
    CustomerReport.cfc and that would be a fine name for an object that can
    return numerous Customer Reports.
    Happy Coding
    DW

  • Join Query hanging

    hi experts,
    please help on this, we have migrated database from 10g to 11.2.0.3 , Everything went sccessful but one of the simple join query hanging occasionally in new upgraded database. is there any known issue or anything need to add after migration for sqls?,also before migration its was executed without any issues. that query is joining and fetching from two more tables . is there any generic reason please provide that would be helpful to analyze, Thanks in Advance.

    why wasn't this discovered during testing prior to the upgrade?
    does new DB have current statistics?
    How do I ask a question on the forums?
    https://forums.oracle.com/forums/thread.jspa?threadID=2174552#9360002

  • Join query getting poor performance

    Hi,
    This is my join query to retriving data , i had a problem from this, its getting very slow to retrive data, even i used in report builder, it could not build the report.
    From this select statement i've using three tables ,
    please help and have suggestion to tune my query better fast and give some new idea , but i'm using oracle 8i.
    select a.customer_code customer, c.name name, c.place place, a.product_code product, b.quantity ord_qty, nvl(b.delivery_district_code,c.district_code) district, nvl(b.delivery_town_code,c.town_code) town
    from order_book a, order_book_detail b, customer c
    where a.region_code = b.region_code
    and a.order_book_form_no = b.order_book_form_no
    and a.customer_code = c.customer_code
    and c.division_code = 34
    and a.region_code = 10
    and c.state_code = 1
    and a.order_book_form_date = '18-OCT-2007'
    and nvl(c.classification_code,'N') = 'S'
    order by 1;
    regards
    venki

    why nobody answering me.Because you gave us nothing to investigate. Please read [url http://forums.oracle.com/forums/thread.jspa?threadID=501834&tstart=0]this thread and post a tkprof output here. For an explain plan in 8i, you could "set autotrace on explain" in SQL*Plus.
    Regards,
    Rob.

  • How can I perform this kind of range join query using DPL?

    How can I perform this kind of range join query using DPL?
    SELECT * from t where 1<=t.a<=2 and 3<=t.b<=5
    In this pdf : http://www.oracle.com/technology/products/berkeley-db/pdf/performing%20queries%20in%20oracle%20berkeley%20db%20java%20edition.pdf,
    It shows how to perform "Two equality-conditions query on a single primary database" just like SELECT * FROM tab WHERE col1 = A AND col2 = B using entity join class, but it does not give a solution about the range join query.

    I'm sorry, I think I've misled you. I suggested that you perform two queries and then take the intersection of the results. You could do this, but the solution to your query is much simpler. I'll correct my previous message.
    Your query is very simple to implement. You should perform the first part of query to get a cursor on the index for 'a' for the "1<=t.a<=2" part. Then simply iterate over that cursor, and process the entities where the "3<=t.b<=5" expression is true. You don't need a second index (on 'b') or another cursor.
    This is called "filtering" because you're iterating through entities that you obtain from one index, and selecting some entities for processing and discarding others. The white paper you mentioned has an example of filtering in combination with the use of an index.
    An alternative is to reverse the procedure above: use the index for 'b' to get a cursor for the "3<=t.b<=5" part of the query, then iterate and filter the results based on the "1<=t.a<=2" expression.
    If you're concerned about efficiency, you can choose the index (i.e., choose which of these two alternatives to implement) based on which part of the query you believe will return the smallest number of results. The less entities read, the faster the query.
    Contrary to what I said earlier, taking the intersection of two queries that are ANDed doesn't make sense -- filtering is the better solution. However, taking the union of two queries does make sense, when the queries are ORed. Sorry for the confusion.
    --mark                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Maybe you are looking for

  • Creating JOB using JOB API - Future Dated value for a segment

    Hi Trying to create a JOB using "hr_job_api.create_job" as of today (17-Jul-2009), with one of the segment value has the 'Date_from' as 26-Jul-2009. API is throwing the below error ORA-20001: FLEX-VALUE IS EXPIRED: ORA-06512: at "APPS.HR_JOB_API", li

  • Apple store widget not working....

    the widget which lets you choose any apple store and then give you the daily schedual for its workshops is not working on my mac, ive reinstalled and and the same thing is happening, the widget shows up but when i have to choose my state/country and

  • How to add uploaded photos (not from aperture) in Mobileme Gallery to a project

    I shared some photos using a mobileme gallery where I allowed friends to upload their photos to the gallery.  Now the gallery exists with both the photos from my aperture library (and project) and my friends photos (which appear in aperture with a li

  • I cant set a home screen background

    I went to photos, saved photos, picked the one i want, then hit set. But instead of having it ask me for the lock or welcome screen it automaticly goes to lock, I have the latest ipod system on the 3rd gen.

  • Re: Express Query on boolean values

    Hi Simon, When the model is run, however, I am able to enter values in the other fields and query on them, but I am unable to change the value of the checkbox that Express generates for the boolean attribute. If the query is run, the data returned is