No Resultset for query containing multiple tables

Hi, I am new to Oracle and I have a problem concerning the Oracle datasource/query I am using.
I am using Websphere Application Server v5.1 Test environment, which connects to an Oracle 10g database and a DB2 database.
So basically, I have 2 datasources in my webservice application, one for each database. I have tested both datasources from the admin console of the server and both return no errors. Both datasources are loaded on startup of the application and again, there are no errors.
The problem basically is that I have no resultset elements ( rs.next() is false ) when I have a query that queries multiple tables.
Eg. Case1: Select * From table1
Case2: Select * From table1, table2
Case3: Select * From table1 t1 INNER JOIN table2 t2 on t1.column = t2.column
Case1: Contains resultset
Case2 and Case3: NO resultset
When these queries (case 2 and case3) are run from within the webservice application, there is no resultset; only case1 returns a resultset. However, if I run the same queries above from within Oracle SQL developer, there is a resultset containing the matching records. This problem only happens when using the Oracle datasource; the same problem does not happen for the DB2 datasource.
Basically, I do not have any resultset for a valid query and there aren't any errors as well.
Any ideas as to why this happens?
Thanks for any help.
Edited by: user11220677 on Jun 3, 2009 3:08 AM

Finally got to the bottom of this. Turns out that the problem has nothing to do with the Oracle datasource in the webservice application, as what I have initiially thought.
The cause of the problem seems to be related to an import problem/issue in the Oracle SQL developer. Everytime I open Oracle SQL developer, one table (table2 in my example from previous post) is missing its data, so I import the data using the application's import wizard. Once the import is done, I use SQL developer's query interface to verify the data is there, and there are records returned - which made me think the database table was updated successfully. The problem was, I still do not have results when the query is run from the webservice containing the datasource.
We used another SQL command editor to verify if the said table was really updated in the database and to our surprise, it was still empty (even after the import from Oracle SQL developer). That explains why I am not able to retrieve anything from the webservice.
We just imported the data using another SQL command editor and the issue is now fixed.
Thanks anyway.

Similar Messages

  • BaseTableName blank when calling GetSchema on a query with multiple tables

    I am using ODP.NET 11.2.0.3.0 and when calling GetSchemaTable on a DataReader that contains a join the returned SchemaTable has the BaseTableName and BaseColumnName fields blank - this is different than what I see with the Oracle OLE DB Provider and with how SQL Server's native provider works. I can't find any discussion of this - is this on purpose or is it a bug? why does the available schema information vary so drastically between a single table query and a query with multiple tables joined?
    Thanks,
    Bryan Hinton

    Hi Bryan,
    I am also facing the same issue. Did u find any work around or any suggestions will be well appreciated.
    Thanks,
    Naresh.

  • Dbms_xmlgen.newcontext query from multiple tables and ||

    I have two questions
    How do I get a dbms_xmlgen.context to query from multiple tables? I have been able to make it work with using one table only, but not with multiple tables.
    And how to get the || (concat) to work within my query for my output to an xml file?
    Here is my current query:
    create or replace function get_xml return clob is
    result clob;
    qryctx dbms_xmlgen.ctxHandle;
    SELECT DBMS_XMLGEN.getxml('select prefix, suffix, fiscal_yr
    FROM rcv.recv_accessions ra
    where ra.prefix = 8 and ra.fiscal_yr = 11')xml into result FROM dual;
    result := DBMS_XMLGEN.getXML(qryCtx);
    This is what I desire:
    SELECT DBMS_XMLGEN.getxml('select ra.prefix||'-'|| ra.suffix||'-'|| ra.fiscal_yr accession, ss.date_in, st.test
    FROM rcv.recv_accessions ra, ser.sero_samples ss, ser.sero_tests st
    where ra.prefix = 8 and ra.fiscal_yr = 11 and ss.raid = ra.id and st.ssid = ss.id')xml into result FROM dual;
    On this both the reference to multiple tables and the concat function cause errors.
    Thank you
    Edited by: user583094 on Mar 2, 2011 3:36 PM

    Hi,
    for the concat do I use xmlconcat?No, XMLConcat is used to concatenate XMLType fragments.
    The || operator will do fine, but you must escape any single quote inside the string :
    SELECT DBMS_XMLGEN.getxml(
    'SELECT ra.prefix ||''-''|| ra.suffix ||''-''|| ra.fiscal_yr as accession,
            ss.date_in,
            st.test
    FROM rcv.recv_accessions ra,
          ser.sero_samples ss,
          ser.sero_tests st
    WHERE ra.prefix = 8
    AND ra.fiscal_yr = 11
    AND ss.raid = ra.id
    AND st.ssid = ss.id'
    INTO result
    FROM dual;Or, use the quoting operator to define a custom string delimiter :
    SELECT DBMS_XMLGEN.getxml(
    q'{SELECT ra.prefix ||'-'|| ra.suffix ||'-'|| ra.fiscal_yr as accession,
            ss.date_in,
            st.test
    FROM rcv.recv_accessions ra,
          ser.sero_samples ss,
          ser.sero_tests st
    WHERE ra.prefix = 8
    AND ra.fiscal_yr = 11
    AND ss.raid = ra.id
    AND st.ssid = ss.id
    INTO result
    FROM dual;BTW, a good practice would be to use bind variables for the query. DBMS_XMLGEN can handle them nicely :
    CREATE OR REPLACE FUNCTION get_xml
    RETURN CLOB
    IS
    qryctx   DBMS_XMLGEN.ctxHandle;
    v_out    CLOB;
    qrystr   VARCHAR2(4000) :=
    'SELECT ra.prefix ||''-''|| ra.suffix ||''-''|| ra.fiscal_yr as accession,
            ss.date_in,
            st.test
    FROM rcv.recv_accessions ra,
          ser.sero_samples ss,
          ser.sero_tests st
    WHERE ra.prefix = :b_prefix
    AND ra.fiscal_yr = :b_fiscal_yr
    AND ss.raid = ra.id
    AND st.ssid = ss.id';
    BEGIN
    qryctx := DBMS_XMLGEN.newContext(qrystr);
    DBMS_XMLGEN.setBindValue(qryctx, 'b_prefix', '8');
    DBMS_XMLGEN.setBindValue(qryctx, 'b_fiscal_yr', '11');
    -- to generate empty elements if necessary :
    DBMS_XMLGEN.setNullHandling(qryctx, DBMS_XMLGEN.EMPTY_TAG);
    v_out := DBMS_XMLGEN.getXML(qryctx);
    DBMS_XMLGEN.closeContext(qryctx);
    RETURN v_out;
    END;

  • Pure SQL of Select query on multiple tables in DB Adapter

    I am trying use pure sql approach for a custom sql query on multiple tables for a DB adapter by modifying toplink_mappings.xml. But i am not getting other tables in my xsd. Please help.

    hi Ravi,
    can you pls be a bit clear? what is this about? where you are using?
    thanks,
    sneha.

  • Mysql query (search multiple tables in database)

    I have 12 tables in a database - january through to december.
    I need to search all 12 tables for 'keyworrd' phrases submitted by the user through a search form.
    Must be a more streamlined way of doing it than below using 'UNION'. I have incorporated 2 tables in the below query but  I need a more 'condensed' query for all 12 tables?
    $sql = ('SELECT * FROM january WHERE tourTitle = "'.$keyword.'" UNION SELECT * FROM february WHERE tourTitle = "'.$keyword.'"');
    Cheers
    Os

    bregent wrote:
    >That's what I did last year but  thought I'd break it down this year into 12 easier to work with tables.
    No, Ben is correct. Using 1 table for each month is absolutely the wrong way. It violates basic rules of normalization and causes all sorts of problems.
    >Breaking it down appeals to be more so I can keep all the relevant months
    >together instead of potentially becoming scattered throught-out one table.
    That's what you use the Order By clause for.
    >If by any chance the client says they want to update x, y or z I can go
    >straight to the month in question without the necessity to flip through
    >dozens of pages in phpMyAdmin as there is no real CMS management in place for this process.
    Not sure what you are saying. Performing inserts, updates and queries is much simpler using a single table.
    Whenever someone asks for a way to search through multiple tables, it tells me that the data structure is not designed well.
    When I did this job last year there was about 60 pages created in phpMyAdmin. The records for January could be anywhere on those 60 pages as I may have to add additional records much later on in the process.
    My thinking behind this was to keep all the month entries together so I could view them easily in phpMyAdmin.
    Now due to my lack of knowlege about phpMyAdmin it could be possible to create a query to show only the january entries, I suspect it can do this.
    I agree it is a lot simpler using 1 table to select and search through BUT I need if the ocassion arises to be able to view all the january or february entries etc one after the other, not 10 on page 2 and 3 on page 7 and 5 more on page 47 of phpMyAdmin.
    So i quess what I really need is to write a select query in phpMyAdmin which only shows the selected entries for the month requested. I have not done much investigation into what phpMyAdmin can do........so I suppose I need to.
    EDITED:
    Arrgh you see IT WAS SO SIMPLE:
    SELECT * FROM `tours` WHERE month = "March"
    It's because I'm frightened of the bloody thing in case I mess something up!

  • How to use one query against multiple table and recieve one report?

    I have duplicate tables, (except for their names of course) with commodities prices. They have the same column headings, but the data is different of course. I have a query that gives me a certain piece of information I am looking for but now I need to run this query against every table. I will do this every day as well, to see if the buying criteria is met. There are alot of tables though (256). Is there a way to say run query in all tables and return the results in one place? Thanks for your help.

    hey
    a. the all 256 tables whuld be one big partitoned table
    b. you can use all_tables in order to write a select that will write the report for you:
    SQL> set head off
    SQL> select 'select * from (' from dual
      2  union all
      3  select 'select count(*) from ' || table_name || ' union all ' from a
      4  where table_name like 'DB%' AND ROWNUM <= 3
      5  union all
      6  select ')' from dual;
    select * from (
    select count(*) from DBMS_LOCK_ALLOCATED union all
    select count(*) from DBMS_ALERT_INFO union all
    select count(*) from DBMS_UPG_LOG$ union all
    remove the last 'union all', and tun the generated quary -
    SQL> set head on
    SQL> select * from (
      2  select count(*) from DBMS_LOCK_ALLOCATED union all
      3  select count(*) from DBMS_ALERT_INFO union all
      4  select count(*) from DBMS_UPG_LOG$
      5  );
      COUNT(*)
             0
             0
             0
    Amiel

  • ALV for fields from multiple tables and make them editable

    Hi,
    I am working on a forecasting report. We have created few custom table e.g. store forcaset detail for whole year month wise. tables are say sales data, budget data, forcast data etc.
    Now i need to make a report based on monthwise based on above mention table.
    eg.o/p looks like:
    column name                     type desc monthapr monthmay .......
    table forcast                      Qty  sales    100          150
    table budget/sales             amt   amou    20.50    130.50
    table sales vs forcast       amt   amount  3000     50000
    -Now i don't know how to display data from multiple table in single ALV list that to with different field type.
    -2nd issue is i need to make only perticuler row editable so that user can chage data.
    -3rd when user change data and press calulate button - it should calculate data for future month - i got formula for that and disply the calulated data.
    - 4th if user like the forcast data then when press save - change data should update dbtable.
    Is this all possible with simple abap FM Or need to use ABAPOO.
    I will appericiate all expert help.
    Many thanks in advance.
    KDE.
    Edited by: kde_test on Jun 4, 2010 5:44 PM

    Hi,
    Solutions :
    1. You can use  FM REUSE_ALV_HIERSEQ_LIST_DISPLAY as guided by Ashutosh.
    You can also check out this
    [http://www.sap technical.com/Tutorials/ABAP/3DGraph/demo.htm]  change link to saptechnical without space
    2. [How to make certain rows in ALV grid editable...;
    3 & 4. Use two importing paramaters 'PF_STATUS_SET' 'USER_COMMAND' of  REUSE_ALV_GRID_DISPLAY.
    create two function codes 'CALC and 'SAVE' in pf-status and provide your required functionality to these function codes using User-Command.
    Sorry am unable to provide you with supporting code, but you can search for it and It can solve your problem
    Regards,
    Rohit

  • Creating a tree query on multiple tables

    I have been reading the following article:
    http://www.oracle.com/technology/oramag/webcolumns/2003/techarticles/gennick_connectby.html#f1
    The diagram 1b that the above links to shows a local government hierrachy structure stored in multiple tables. I am having a little difficulty understanding how you would write a query (using start with connect by syntax) to get the data displayed in a tree format??
    ie: (spaces are being removed so replaced them with --)
    state1
    --county1
    --county2
    ----township1
    ----township2
    --county3
    state2
    state3
    --county3
    --county4                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    hi, please post a sample data it would help us to further analyze. thanks.
    here is some example that might help
    NODE_DATA                                NODE_PAREN
    CAR                                      TRANSPORT
    PLANE                                    TRANSPORT
    BIKE                                     TRANSPORT
    TRANSPORT
    HONDA                                    CAR
    747-400                                  PLANE
    MAZDA                                    CAR
    FOOD
    FRUIT                                    FOOD
    VEGETABLE                                FOOD
    SPINACH                                  VEGETABLE
    CARROT                                   VEGETABLE
    12 rows selected.
    SQL> select substr(rpad(' ',decode(level,1,0,2,2,4),' ')||node_data,1,20) node_data
      2    from myTreeData
      3  start with node_parent is null
      4  connect by node_parent = prior node_data;
    NODE_DATA
    TRANSPORT
      CAR
        HONDA
        MAZDA
      PLANE
        747-400
      BIKE
    FOOD
      FRUIT
      VEGETABLE
        SPINACH
        CARROT
    12 rows selected.
    SQL>

  • Optimizing the query containing 7 table joins

    hi,, I have a query which is taking almost 20 minutes to retrieve the data from DB. let me know how can i further optimize the query.. the tables contains huge amount of data
    Table1 a -> 1040131 rows
    Table2 b -> 1040131 rows
    Table3 c -> 2080262 rows
    Table4 d -> 2749 rows
    Table5 e -> 1040131 rows,
    Table6 f -> 93819 rows
    Table7 g -> 99203 rows
    My query is
    SELECT a.lid, g.image, f.product , d.manufacturer, b.desc, c.price, c.abbr, c.currency, c.class
    FROM
    Table1 a,
    Table2 b,
    Table3 c,
    Table4 d,
    Table5 e,
    Table6 f,
    Table7 g
    WHERE (UPPER(b.desc) like '%TEST%' OR UPPER(b.desc) like '%BEST%')
    and a.line = b.line
    AND a.line = c.line
    AND c.subset = 576
    AND a.manufacturer = d.manufacturer
    AND a.line = e.line
    and a.product = f.product
    and e.image = g.image
    Please tell me how can i optimize this query further to work faster

    user1708333 wrote:
    WHERE (UPPER(b.desc) like '%TEST%' OR UPPER(b.desc) like '%BEST%')
    I would imagine that that line is the main culprit.
    You are doing a free text search which will always result in a full table scan the way you are doing it.
    If you need free text searching then you should consider using [Oracle Text|http://www.oracle.com/technology/products/text/index.html]

  • SQL query with multiple tables - what is the most efficient way?

    Hello I am learning PL/SQL. I have a simple procedure where I need to find number of employees and departments per location as per user input of location_id.
    I have 3 Tables:
    LOCATIONS
    location_id (pk)
    location_name
    DEPARTMENTS
    department_id (pk)
    location_id (fk)
    department_name
    EMPLOYEES
    employee_id (pk)
    department_id (fk)
    employee_name
    1 Location can have 0-MANY Departments
    1 Employee has 1 Department
    Here is the query I came up with for PL/SQL procedure:
    /*Ecount, Dcount are NUMBER variables */
    SELECT SUM (EmployeeCount), COUNT(DepartmentNumber)
         INTO Ecount, Dcount
         FROM     
         (SELECT COUNT(employee_id) EmployeeCount, department_id DepartmentNumber
              FROM employees
              GROUP BY department_id
              HAVING department_id IN
                        (SELECT department_id
                        FROM departments
                        WHERE location_id = userInput));
    I do get the correct result, but I am just wondering if my query is on the right track and if there is a more "efficient" way of doing this.
    Thanks in advance for helping a newbie out.

    Hi,
    Welcome to the forum!
    Something like this will be more efficient:
    SELECT    COUNT (employee_id)               AS ECount
    ,       COUNT (DISTINCT department_id)     AS DCount
    FROM       employees
    WHERE       department_id IN (     SELECT     department_id
                        FROM      departments
                        WHERE      location_id = :userInput
    ;You should also try a join instead of the IN subquery.
    For efficiency, do only the things you need to do.
    For example, you don't need a count of employees in each department, so don't compute one. That means you won't need the in-line view, so don't have one.
    You don't need PL/SQL for this job, so don't use PL/SQL if you don't have to. (I realize this question was out of context, so you may have good reasons for doing this in PL/SQL.)
    Do all filtering as early as possible. Don't waste effort computing things that won't be used .
    A particular example of this is: Never use a HAVING clause when you can use a WHERE clause. What's the difference between a WHERE clause and a HAVING clause? The WHERE clause is applied before aggregate functions are computed, and the HAVING clause is applied after; there's no other difference. Therefore, if the HAVING clause isn't referencing an aggregate function, it could be done in a WHERE clause instead.

  • How to generate a query involving multiple tables(one left join others)

    Hi, all,
    I want to query a db like these:
    I need all the demographics information(from table demo) and their acr info(from table acr), and their clinical info(from table clinical), and their lab info(from table lab).
    The db is like this:
    demo->acr: one to many
    demo->clinical info: one to many
    demo->lab info: one to many
    I want to get one query result which are demo left join acr, and demo left join clinical, and demo left join lab. I hope the result is a record including demo info, acr info, clinical info, and lab info.
    How could I do this in SQL?
    Thanks a lot!
    Qian

    Thank you very, very much!
    Actually, I need a huge query to include all the tables in our db.
    We are running a clinical db which collects the patients demographics info, clinical info, lab info, and many other information.
    The Demographics table is a center hub which connects other tables. This is the main architecture.
    My boss needed a huge query to include all the information, so others could find what they need by filtering.
    As you have found, because one patients usually has multiple clinical/lab info sets, so the result will be multiplied! the number of result=n*m*k*...
    My first plan is to set time point criteria to narrow all the records with one study year. If somebody needs to compare them, then I have to show them all.
    So I have to know the SQL to generate a huge query including as many tables as possible.
    I show some details here:
    CREATE TABLE "IMMUNODATA"."DEMOGRAPHICS" (
    "SUBJECTID" INTEGER NOT NULL,
    "WORKID" INTEGER,
    "OMRFHISTORYNUMBER" INTEGER,
    "OTHERID" INTEGER,
    "BARCODE" INTEGER,
    "GENDER" VARCHAR2(1),
    "DOB" DATE,
    "RACEAI" INTEGER,
    "RACECAUCASIAN" INTEGER,
    "RACEAA" INTEGER,
    "RACEASIAN" INTEGER,
    "RACEPAC" INTEGER,
    "RACEHIS" INTEGER,
    "RACEOTHER" VARCHAR2(50),
    "SSN" VARCHAR2(11),
    PRIMARY KEY("SUBJECTID") VALIDATE
    CREATE TABLE "IMMUNODATA"."ACR" (
    "ID" INTEGER NOT NULL,
    "THEDATE" DATE ,
    "SUBJECTID" INTEGER NOT NULL,
    "ACR_PAGENOTCOMPLETED" VARCHAR2(1000) ,
    "ACR_MALARRASHTODAY" INTEGER ,
    "ACR_MALARRASHEVER" INTEGER ,
    "ACR_MALARRSHEARLIESTDATE" DATE ,
    PRIMARY KEY("ID") VALIDATE,
    FOREIGN KEY("SUBJECTID") REFERENCES "IMMUNODATA"."DEMOGRAPHICS" ("SUBJECTID") VALIDATE
    CREATE TABLE "IMMUNODATA"."CLIN" (
    "ID" INTEGER NOT NULL,
    "THEDATE" DATE ,
    "SUBJECTID" INTEGER NOT NULL,
    "CLIN_PAGENOTCOMPLETED" VARCHAR2(1000) ,
    "CLIN_FATIGUE" VARCHAR2(20) ,
    "CLIN_FATIGUEDATE" DATE ,
    "CLIN_FEVER" VARCHAR2(20) ,
    "CLIN_FEVERDATE" DATE ,
    "CLIN_WEIGHTLOSS" VARCHAR2(20) ,
    "CLIN_WEIGHTLOSSDATE" DATE ,
    "CLIN_CARDIOMEGALY" VARCHAR2(20) ,
    PRIMARY KEY("ID") VALIDATE,
    FOREIGN KEY("SUBJECTID") REFERENCES "IMMUNODATA"."DEMOGRAPHICS" ("SUBJECTID") VALIDATE
    Other tables are alike.
    Thank very much!
    Qian

  • Best workaround for querying across multiple Data Sets?!

    Hi folks
    Today I was migrating my older OEID 3.0 applications to 3.1, and I noticed some of my older version views are not working anymore in new version.
    We used to have multiple Bulk Add/Replace (without specifying Collection Keys) and we could use any attributes from any of these, in a certain View for example.
    My views were like SELECT SUM("an attribute/metric from Bulk Add_1") / SUM("an attribute/metric from Bulk Add_2")
    Now that you have to specify a FROM clause in your views, and it has to be from a certain Data Set, whats the best way to achieve above line goal?
    Bests,

    Patrick
    What I meant by Cross Join is Cartesian Product in situation that you have many-to-many relations between 2 Data Sets
    Lets say, I have to different data, coming from 2 totally different source, one from Sales Dept and the other one from Purchase Dept:
    Sales Table:
    Part Number
    Sales QTY
    Sales Date
    Part Type
    Manufacturer
    Country
    0001
    70
    10/5/2012
    TYPE1
    Manuf1
    US
    0001
    120
    10/6/2012
    TYPE1
    Manuf1
    US
    0001
    350
    10/7/2012
    TYPE1
    Manuf1
    US
    0002
    100
    10/8/2012
    TYPE2
    Manuf2
    US
    0002
    80
    10/9/2012
    TYPE2
    Manuf2
    CA
    0003
    2500
    10/10/2012
    TYPE3
    Manuf3
    CA
    0004
    180
    10/11/2012
    TYPE4
    Manuf4
    US
    Purchase Table:
    Part Number
    Purchase QTY
    Purchase Date
    Part Type
    Manufacturer
    Country
    0001
    50
    10/5/2012
    TYPE1
    Manuf1
    US
    0001
    60
    10/6/2012
    TYPE1
    Manuf1
    US
    0001
    100
    10/7/2012
    TYPE1
    Manuf1
    US
    0001
    200
    10/8/2012
    TYPE1
    Manuf1
    US
    0002
    1100
    10/9/2012
    TYPE2
    Manuf2
    US
    0003
    20
    10/10/2012
    TYPE3
    Manuf3
    US
    What is the preferred approach to ingest this data?

  • SQL query involving multiple tables

    I have a scenario in SQL where For each post there are associated tags. A user is one who makes post and he belongs to a particular location. The location corresponds to a particular country.
    I create tables as
    CREATE TABLE post_table
    post_id VARCHAR(20),
    user_id VARCHAR(20),
    PRIMARY KEY(post_id)
    CREATE TABLE tags_table
       post_id VARCHAR(20),
       tags VARCHAR(20),
       PRIMARY KEY(tags, post_id),
       FOREIGN KEY(post_id) REFERENCES post_table(post_id) ON DELETE CASCADE
    CREATE TABLE location
    location_id VARCHAR(20),
    country VARCHAR(20),
    PRIMARY KEY (location_id)
    CREATE TABLE user_info
    user_id VARCHAR(20),
    location_id VARCHAR(30),
    PRIMARY KEY (user_id),
    FOREIGN KEY(location_id) REFERENCES location(location_id) ON DELETE CASCADE
    );Now, I insert values in these tables as
    INSERT INTO post_table VALUES( 'p1', 'u1' );
    INSERT INTO post_table VALUES( 'p2', 'u1' );
    INSERT INTO post_table VALUES( 'p3', 'u2' );
    INSERT INTO post_table VALUES( 'p4', 'u3' );
    INSERT INTO post_table VALUES( 'p5', 'u2' );
    INSERT INTO tags_table VALUES( 'p1', 'US Open' );
    INSERT INTO tags_table VALUES( 'p1', 'Real good' );
    INSERT INTO tags_table VALUES( 'p1', 'Madrid' );
    INSERT INTO tags_table VALUES( 'p2', 'Madrid' );
    INSERT INTO tags_table VALUES( 'p3', 'Rossoneri' );
    INSERT INTO tags_table VALUES( 'p4', 'Milan' );
    INSERT INTO tags_table VALUES( 'p4', 'Los Angeles' );
    INSERT INTO tags_table VALUES( 'p5', 'Rossoneri' );
    INSERT INTO location VALUES( 'loc1', 'Spain');
    INSERT INTO location VALUES( 'loc2', 'England');
    INSERT INTO user_info VALUES( 'u1', 'loc1' );
    INSERT INTO user_info VALUES( 'u2', 'loc2' );
    INSERT INTO user_info VALUES( 'u3', 'loc1' );Now I have to fire a query For each country, display the most seen tag(s)
    So for this data the result should be like
    Country              MostTags
    Spain                Madrid
    England              RossoneriPlease help me write this query guys.

    Hi,
    Something like this
    select      country
         , tags from
                 select      l.country
                   , t.tags
                   , dense_rank() over (     partition by l.country
                                  order by count(*) desc) drn
              from      location l
                   , user_info u
                   , post_table p
                   , tags_table t
              where      l.location_id = u.location_id
                   and p.user_id=u.user_id
                   and p.post_id=t.post_id
              group by l.country
                   , t.tags
    where drn <=1   -- rank depends on like 1,2 or 3 popular tags for each countryRegards
    Anurag

  • Select List or Radio Buttons query with multiple tables join

    Hello,
    I'm having a problem creating a select list or a radio group item.
    I need to display the emp_first_name in the select list but have the return value of the order_id in the select list or radio buttons item.
    The tables are as follow:
    emp_table
    emp_id
    emp_first_name
    emp_last_name
    etc...
    orders_table
    order_id
    order_name
    emp_id
    etc...
    I need to display the emp_name from emp_table in the select list but return the order_id from the orders_table as the return value.
    How can I do this?
    Any help would be greatly appreciated.
    Thanks.
    Regards,
    NJ

    Hi NJ,
    Try:
    select e.emp_first_name d,
    o.order_id r
    from orders_table o
    inner join emp_table e on o.emp_id = e.emp_id
    order by 1You may have an issue with an emp_id being used for more than one order and, therefore, the employee's name appearing more than once in the list?
    Andy

  • Correlation for files containing multiple records

    I was learning correlation from a nice blog below.
    /people/milan.thaker/blog/2008/07/23/correlation-150-runtime-behavior-of-bpm
    I have one question though. In the case where the correlation is done on  a key field say PsNo.
    Now if two files have multiple records, will the correlation compare the PsNo of each record or is the comparison just on the first PsNo of each file record.
    Thanks,
    Minhaj.

    Hi Minhaj,
    1) Suppose if you want to merge 2 files into a single file based on a keyfield (PsNo), You are opting Correlation in BPM.
    In your Correlation Editor, You should mention the XPATH Expression for Keyfield(PsNO) for the involved messages.
    2) Only if both the values of keyfied(PsNo) in 2 files are equal then Only you can merge all those 2 files into single file.
    So first PsNo of each file record is going to compared with another file.

Maybe you are looking for

  • Problem when writing a value to an enum

    Hi together, I'm facing a problem when using an enum in my state machine. From time to time, the value (which represents the next state) which comes from the shiftregister, is not stored correctly into my enumvariable.When I probe point "1", a differ

  • Apple id changed

    When i got my first iphone, i registred Apple id, for example myappleid@***.com Few months later i decided to change it using my profile, so i had a new one myappleid2@***.com. Everything worked allright, all my stuff syncronized. But now i checked m

  • Another question about using objects in SQL queries

    Hi gurus, I need your thoughts on this: I have created generic object type "tree" - the constructor takes as a parameter sql query returning "node_id" and "parent_node_id". As a tree - the object has all related to a tree structure member functions a

  • Amendment sales order

    Hi all, I am creating sales order with reference to customer sales order. later, customer corrects something in that purchase order and again send it to us. For that, we need to create amendment sales order and we have to mention amendment number. Ho

  • PPDS Subcontracting Process

    Hello Experts, I am trying to replicate the subcontracting process through PP/DS run. Business case: Handover the components from the destination location (DEST) to the subcontracting vendor (SUBV) to manufacture the finished goods. There is absolute