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>
Similar Messages
-
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 PMHi,
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; -
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 HintonHi Bryan,
I am also facing the same issue. Did u find any work around or any suggestions will be well appreciated.
Thanks,
Naresh. -
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
Osbregent 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! -
Creating a form that populates multiple tables
Hi,
I need to create a registration form which inserts data into multiple tables (USERS (master-table), PHONES, ADDRESSES, EMAILS, etc) at once. I've been looking through the docs and the only way I've found yet is to build the form on a procedure. Other methods have restriction on using maximum of 2 tables.
What is the best approach for building a form on multiple tables in htmldb?Either do it on a procedure, or simply write the insert in Process yourself:declare
l_new_deptno number;
begin
insert into dept(dname)vales(:P1_DNAME) returning deptno into l_new_deptno;
insert into emp(ename,sal,deptno)
values (:P1_NAME,:P1_SALARY,l_new_deptno);
end;Thanks,
Tyler -
URGENT: CREATE A TREE USING ROWS OF TABLE
problem:
Task-id Start-dt Fininsh-date
1
2
WITH IN A TABLE I NEED TO MAKE [ROW 2] AS A CHILD OF [ROW 1] USING -> BUTTON .
ROW 2 BECOMES INDEPENDENT IF I USE <- BUTTON.
I CREATED A TABLE STRUCTURE THAT CAN INSERT ROWS AND COLUMNS DYNAMICALLY.
BUT I NEED TO MAKE A TREE STRUCTURE AT RUNTIME USING BUTTONS.
CAN ANY BODY HELP ME WITH SOME CODE?I seems we have two option that both a not sufficient (Gurus, please correct me):
1. Base the tree on an existing JSP page. This is what the default ViewHandler of each JSF implementation must offer. According to the spec you can add/remove from that tree. The drawback is that the JSP page must exist so you cannot really create a new tree unless you create a new JSP file before.
2. Implement your own ViewHandler and register it with your web application's LifeCycle. The major drawback here is that you have to implement the rendering of each and every component and of the whole rendering logic yourself.
What we do need (while sticking to the default ViewHandler) is a means to create new trees with tree IDs that do not necessarily denote JSP pages. A new tree could optionally be based on an existing JSP page. This way we could have a few JSP templates and could create many tree instances where several different trees could be derived from the same JSP template.
Hey, spec designers, what do you think about that? -
Need to create an ABAP query on 2 tables BSIK and BSAK
Hi,
I need to create an ABAP query which has the fields document no, doc date, amount in doc currency and some other fields from 2 tables BSIK and BSAK. Is it possible to write a single abap query to fetch the data from both the tables.
The selection screen fields are doc number, date and doc type.
I need to display invoices for open items and cleared items together.
Please let me know if this is possible.
Thanks and Regards,
AjithSee if this is anything like what you need:
REPORT ztest MESSAGE-ID 00.
TABLES: bkpf, bseg.
SELECT-OPTIONS: s_bukrs FOR bkpf-bukrs,
s_belnr FOR bkpf-belnr,
s_gjahr FOR bkpf-gjahr,
s_blart FOR bkpf-blart,
s_budat FOR bkpf-budat.
DATA: BEGIN OF bkpf_int OCCURS 0.
INCLUDE STRUCTURE bkpf.
DATA: END OF bkpf_int.
DATA: BEGIN OF bseg_int OCCURS 0.
INCLUDE STRUCTURE bseg.
DATA: END OF bseg_int.
DATA: BEGIN OF bsik_int OCCURS 0.
INCLUDE STRUCTURE bsik.
DATA: END OF bsik_int.
SELECT *
FROM bkpf
INTO TABLE bkpf_int
WHERE bukrs IN s_bukrs
AND belnr IN s_belnr
AND gjahr IN s_gjahr
AND blart IN s_blart
AND bldat IN s_budat.
SORT bkpf_int BY bukrs belnr gjahr.
SELECT *
FROM bseg
INTO TABLE bseg_int
FOR ALL ENTRIES IN bkpf_int
WHERE bukrs = bkpf_int-bukrs
AND belnr = bkpf_int-belnr
AND gjahr = bkpf_int-gjahr
AND koart = 'K'.
SORT bseg_int BY bukrs belnr gjahr buzei.
LOOP AT bseg_int.
MOVE-CORRESPONDING bseg_int TO bsik_int.
READ TABLE bkpf_int WITH KEY
bukrs = bseg_int-bukrs
belnr = bseg_int-belnr
gjahr = bseg_int-gjahr
BINARY SEARCH.
IF sy-subrc = 0.
MOVE-CORRESPONDING bkpf_int TO bsik_int.
APPEND bsik_int.
ELSE.
MESSAGE e001 WITH 'Error during read'.
ENDIF.
ENDLOOP.
Rob -
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 AMFinally 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. -
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 -
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!
QianThank 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 -
How to create af:tree from single database Table
Hi,
i want to create tree Like this: and also we can add node anywhere.
Parent01
----|parent01-child01
--------|parent01-child01-child01
--------|parent01-child01-child02
-------------|parent01-child01-child02-child01
Parent02
----|parent02-child01
----|parent02-child02
--------|parent02-child02-child01
and for this i have created Table like this :
Table name Treetable
NODEID NUMBER(38,0) --> Primary Key
NODENAME VARCHAR2(50 BYTE) --> This is the name will display as a node
DESCRIPTION VARCHAR2(255 BYTE)
ROOTIND CHAR(1 BYTE) --> to decide root node
SEQUENCENO NUMBER(38,0) --> order to display node
PARENTKEY NUMBER(38,0) -->FK (refering to NODEID(PK) of this table)
But when i am creating tree, its showing root node for each row in the table. but my requirement is: The Row marked as ROOTIND='Y' , show that row only as Root (Example in above tree:Parent01 & Parent02 )
any help highly appreciated :)
Thanks
Pratap Rudra
Edited by: 995114 on Apr 30, 2013 2:50 PMHi,
check this http://www.oracle.com/technetwork/developer-tools/adf/learnmore/32-tree-table-from-single-vo-169174.pdf
Frank -
Create Trigger to Delete from multiple tables
Hello:
I'm trying to write a trigger which will allow me to delete from multiple records. I have two tables where the record for the same client_id needs to be deleted.
Is it possible to do this? I started writing some code and this is what I have so far:
create or replace trigger app_t1
before delete on <table1> ?? -
for each row
begin
delete from client where clientid = :new.clientid;
delete from key where pk = :newclientid;
end;I'm stuck on the line where I have "before delete on" where I'm supposed to provide a table name. I can only use one table and I need to delete from two.
This trigger is supposed to be used within APEX. In APEX, fields are designated as :P1_clientid where P1 references page 1 of the application. Yet, :P1_clientid is set to the field clientid in the table.
So when I write my trigger, I'm not sure how I'm supposed to set my variables.
Can someone help?
I'm also going to post this into the APEX forum.
Thanks.It's not clear to me if you are just trying to keep two tables in syn or whether you are trying to achieve something else.
A couple of points though:
- In delete database triggers the :new attributes are NULL. You probably mean to use the :old attributes.
- Is there some relationship between the two tables? If so, setting the foreign key to CASCADE DELETE might do the trick for you.
- Another option - better than a database trigger in my opinion - is to just code a procedure that deletes from both tables and call that one from APEX.
Regards,
Rob. -
Create a text index on multiple tables
I have read the same forum questions a thousand times about doing this and the only thing they show examples of is using multiple columns in one table.
Here is what I have:
create table documents_a
(id number,
text blob);
create table documents_b
(id number,
text blob);
create table documents_c
(id number,
text blob);
I want to be able to do a text search over all three tables on the blob column. I can't use the multi_column_datastore because from what I read this can only be used with one table.
I eventually want to be able to bring up a snippet of the text that contains the keywords and a link to the actual document.
How do I build a text index that includes each blob column from each of the three tables?OK so I created the materialized view
create materialized view alltabs as
select a.id, a.text, b.id, b.text, c.id, c.text
from tablea a, tableb b, tablec c;
and I created the following
ctx_ddl.create_preference(my_multi', "MULTI_COLUMN_DATASTORE');
ctx_ddl.set_attribute('my_multi','columns','a_document, b_document, c_document');
Then I attempted but I am not sure what column name to put in the pararens?
create index multi_tab on alltabs(????)
indextype is ctxsys.context
parameters('datastore my_multi sync(on commit)');
I saw a dummy column created in most of the internet examples but just exactly what gets created here? I want to create a multi column index so didn't I already tell it which columns up above? -
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
Maybe you are looking for
-
IMovie won't open library... spiking processor
I went into the iMovie library though the finder and deleted one of the events folders that wasn't showing up in iMovie (I did this because iMovie crashed on import and wouldn't recognize that those files were even there) After I deleted the folder,
-
Hyperlinks in FrameMaker 8 File don't work consistently when PDF'd
I have a FrameMaker 8 file with internal hyperlinks. When I test them in FrameMaker they work but when I PDF the file SOME of them are not working. I'm using Acrobat 8 as well.
-
How to cache data from database
Hi all, How can i cache the data from a database, so that i don't have to go to database again and again to get the same results. thanks in advance gcs
-
Mail 4.3 not working after installing combo
I had problems with my mail after installing snow leopard and then having one failed software update. I then installed the combo. It seemed to successfully install the mail app and then When i opened it, it said to wait while my mailboxes were rebuil
-
Help with HTTP protocol.
Hi every body. How can I get HTML code from some page in the internet with GET data and POST data? OR How can use on the usualy sockets like TelNET? I saw the MXLsocket class, this is the same thing? TNX all.