SQL query....need help again
Actor (Aname: varchar(40), Ano: varchar(6)) Ano is pk
Movie (Mname: varchar(40),mno: varchar(8)) Mno is pk
PlayIn (Ano, Mno, Pay: Integer) Ano and Mno are fk referencing Acotr and Movie respectively.
Actor(Aname, Ano)
A Bingo, A1
B Castro, A2
C Katie, A3
S Hommy, A4
J Tammy, A5
K loren, A6
Movie(Mname, Mno)
Gladiator, M1
Cast, M2
Dog, M3
Jilters, M4
PlayIn(Ano,Mno,Pay)
A1 M1 800
A1 M2 1500
A2 M2 78
A2 M3 1750
A2 M4 2301
A3 M2 904
A3 M3 629
A4 M2 565
A4 M3 5695
A4 M4 1255
A5 M1 989
A5 M4 238
A6 M2 137
A6 M3 236
A6 M4 545
write a query for this QUESTION:
for each movie, list the movie number, the average pay and the total number of actors in the movie.....
hi - didn't you read my response to your other nearly identical thread?
SQL query...pls help ASAP
may I suggest you get a basic book on oracle SQL and immerse yourself for a few hours before comming to this forum for answers to your homework questions?
Similar Messages
-
Hi All,
We have a native SQL query accessing Oracle database(given below).
Can anyone please let me know what this query is about and how can we fine tune the query?
SELECT O.OBJECT_NAME ,
H.SID,
HS.MACHINE,
HS.PROCESS,
W.SID,
WS.MACHINE,
WS.PROCESS,
H.CTIME,
W.CTIME,
WS.ROW_WAIT_OBJ#,
WS.ROW_WAIT_FILE#,
WS.ROW_WAIT_BLOCK#,
WS.ROW_WAIT_ROW#,
HP.SPID,
WP.SPID
FROM V$LOCK H, V$LOCK W, V$LOCK I, V$LOCK I2, ALL_OBJECTS O,
V$SESSION HS, V$SESSION WS, V$PROCESS HP, V$PROCESS WP
WHERE H.ID1 = W.ID1
AND H.SID <> W.SID
AND H.TYPE IN ('TX','DL')
AND H.REQUEST = 0
AND H.SID = I.SID
AND I.TYPE = 'TM'
AND I.ID1 = O.OBJECT_ID
AND I.ID1 = I2.ID1
AND W.SID = I2.SID
AND I2.TYPE = 'TM'
AND H.SID = HS.SID
AND W.SID = WS.SID
AND HS.PADDR = HP.ADDR
AND WS.PADDR = WP.ADDR
INTO :EXCL_LOCK_WAITERS-OBJ_NAME ,
:EXCL_LOCK_WAITERS-HOLDER_SID ,
:EXCL_LOCK_WAITERS-H_HOSTNAME ,
:EXCL_LOCK_WAITERS-HOLDER_PID ,
:HOLDER_PID ,
:EXCL_LOCK_WAITERS-WAITER_SID ,
:EXCL_LOCK_WAITERS-W_HOSTNAME ,
:EXCL_LOCK_WAITERS-WAITER_PID ,
:WAITER_PID ,
:EXCL_LOCK_WAITERS-HELD_SINCE ,
:EXCL_LOCK_WAITERS-WAITSSINCE,
:ROW_WAIT_OBJ,
:ROW_WAIT_FILE,
:ROW_WAIT_BLOCK,
:ROW_WAIT_ROW,
:H_PROCESS,
:W_PROCESS
ENDEXEC
Thanks in advance.
Neethu MohanHi Neethu,
It gives you an overwiew of blocking Oracle sessions.
1. In general, the SQL checks Oracle sessions (SID's) that were requirering a DML lock ('TM') and now holding row locks (TX) to prevent destructive interference of simultaneous conflicting DML or DDL operations. DML statements automatically acquire both table-level locks and row-level locks ('TX') => holders
It joins these with the sessions that are waiting of releasing the lock by the holders => waiters.
2. it retrieves the detail information wich Oracle process , the object (table) , it's row , block and file
are affected by the locks.
3. Normally, the locks are only hold for a short period of time. If you have blocking sessions it may be of a log running task (i.e. mass data update of a table) ; but it could also be a application bug due to improper handling of concurrent updates of the same object.
4. Tuning
V$tables are expensive to query: Why?
v$ tables are generally Oracle memory structures.
v$ tables are not read consistent.
v$ tables require latches to access -- cannot modify and read memory at the same
time.
heavy access to v$ tables like this may cause some serious heavy duty contention.
Especially if you self join V$lock several times.
So the best would be to save the contents of V$LOCK in some table:
Create table mylocks as select * from v$lock;
Use that table for self-joining and joins to the other tables.
You can also CTAS the other v$ tables to bypass the performance bottleneck while retrieving
v$ directly.
You can empty or drop the created tables any time for new data.
Because you want to investigate only lock hold for a longert time to copy the v$ memory structures into
physical tables is not a disadvantage. You certainly will wait longer on finishing your query
instead of copy them into the tables.
Hope this helped
yk -
Sql Query need to extract the Work Flow information from Hyperion Planning
Can Any one give me the sql query to extract the Work flow from Hyperion Planning in 11.1.2.1.
I can extract from the Hyperion Planning but it is not in required format again I need to do lot of formating. I need the information as per the flow structure is showing linke in one perticular planning unit in all coloumn format. Hence only sql query will help me to extract this kind of information. could any one provide the sql query to extract this kind of request.
Thanks in Advance.
Edited by: 987185 on Feb 9, 2013 10:57 PMIf you have a look at the data models in - http://www.oracle.com/technetwork/middleware/bi-foundation/epm-data-models-11121-354684.zip
There is the structure of the planning application tables, have a look at the HSP_PM_* tables
Alternatively you can look at extracting the information using LCM.
Cheers
John
http://john-goodwin.blogspot.com/ -
SQL query needed to identify cancelled invoice where distribution lines
SQL query needed to identify cancelled invoice where distribution lines Debit is not equal Credit line item in particular
Is there a way from back end FROM ap_invoice_distributions_all where we can find for the cancelled invoice where distribution lines Debit is not equal Credit line item
Regards,
Prakash RanjanHello Prakash
Can you please see if this query helps you?
SELECT i.invoice_id, i.invoice_amount, nvl(sum(d.amount),0)
FROM ap_invoice_distributions_all d, ap_invoices_all i
WHERE i.org_id = <you org_id>
AND i.invoice_id = d.invoice_id
AND d.line_type_lookup_code not in ('PREPAY')
AND i.cancelled_date IS NOT NULL
GROUP BY i.invoice_id, i.invoice_amount
HAVING (i.invoice_amount <> nvl(sum(d.amount),0))
ORDER BY i.invoice_id asc
Octavio -
I am trying to put a banner on my website for my exam.... It will have to have an image with logos flashing across and stopping for a few seconds before carrying on.and out the other side. I have looked up everywhere to see how this is done but with no joy. There is lots of info out there but it is not working for me. In Flash i have no problem creating a banner image with various logos moving from one side to the other or even changing the image from one shape to another or bouncing it up and down the stage from one side to the other. I can even stagger the timelines for the logos to make them enter one after the other. The one thing i can not get to grips with is making the images stop or pause after they have entered from one side before exiting the other side. I have followed step by step many youtube tutorials but the authors are wizzing through them too fast and despite folling every step second by second, i am missing a vital step somewhere. Would someone please let me know step by step (and please assume i am an idiot when doing this) the sequence i must follow from the very begining to the last step when i publish.
Noooooooo........ When i saw your email notification i had high hopes of getting the answer i have been trying to work out for two days....but no problem ..your still a legend ha ha ... you got me out of a big hole in this project the last time... but thanks for taking the time to reply, i will try the other forum.
Date: Thu, 26 Jan 2012 17:28:18 -0700
From: [email protected]
To: [email protected]
Subject: News "FLASH"... Nancy O (the legend) ... i need help again
Re: News "FLASH"... Nancy O (the legend) ... i need help again created by Nancy O. in Dreamweaver - View the full discussion
You'll get better answers in the Flash Forums for whichever Action Script ver you're using.
Sorry. I don't do much Flashy stuff anymore. As far as I'm concerned, when Apple iDevices quit supporting Flash, it became a dying web technology.
Nancy O.
Alt-Web Design & Publishing
Web | Graphics | Print | Media Specialists
http://alt-web.com/
http://twitter.com/altweb
Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: http://forums.adobe.com/message/4167793#4167793
To unsubscribe from this thread, please visit the message page at http://forums.adobe.com/message/4167793#4167793. In the Actions box on the right, click the Stop Email Notifications link.
Start a new discussion in Dreamweaver by email or at Adobe Forums
For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746. -
Need Help again...
Hi all...
Really need help again this time...
I am trying to do a web page and thought of placing 4 video
clips into
1 Loader...viewers can simply choose any of the videos they
would like
to watch...and all the video clips will then play in the same
Loader on
the exact X & Y values...Is it possible?
eg. 4 Buttons with linking to 4 different video clips.
When a video clip selected, play in a Loader of X and Y
values.
When another clip selected, play in the same Loader.
Moca or anyone...please help me a.s.a.p...Thanks in
advance...Does this happen to a wired computer or to a wireless computer? If it happens to a wireless computer ONLY but not to a wired computer, a firmware upgrade might not be necessary at all.
Make sure your wireless settings are personalized, try using channel 11 and when you go to advanced wireless settings, try setting the beacon interval to 50 instead of 100.
On how to do the things mentioned in the 2nd paragraph, open up IE and type on the address bar the numbers 192.168.1.1 (username leave it blank, password as a default is admin). Go the the Wireless tab. -
Cluster bar chart- sql query please help-
Hi,
I am trying to create cluster bar chart and am stumped with this sql query.Any help is appreciated.
Here is my table
city region issue value
c1 north i1 y
c1 north i2 y
c2 north i1 n
c2 north i2 y
c3 south i1 y
c3 south i2 n
c4 east i1 n
c4 east i2 n
The bar chart will have 3 series, north south and east.
And labels will be i1 and i2. value will be number of times this issue was encountered(y) in this region.
How can I get something like this from the above table-
region issue count(yes)
north i1 1
north i2 2
south i1 1
south i2 0
east i1 0
east i2 0
thanksWITH table1 AS
(SELECT 1435177 qte_id, 2 seq_no
FROM dual
UNION ALL
SELECT 1435177 qte_id, 5 seq_no
FROM dual
UNION ALL
SELECT 1435177 qte_id, 7 seq_no
FROM dual
UNION ALL
SELECT 1435177 qte_id, 8 seq_no
FROM dual
UNION ALL
SELECT 1435177 qte_id, 12 seq_no
FROM dual
UNION ALL
SELECT 1435177 qte_id, 14 seq_no
FROM dual
table2 AS
SELECT 1435177 qte_id, 1 seq_no, 98500 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 2 seq_no, 98500 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 3 seq_no, 0 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 4 seq_no, 98500 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 5 seq_no, 98500 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 7 seq_no, 98500 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 8 seq_no, 98500 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 11 seq_no, 59300 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 12 seq_no, 59300 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 14 seq_no, 59300 cmmt_curr_amt
FROM dual
SELECT qte_id, t2_seq_no, cmmt_curr_amt - cmmt_curr_lag diff
FROM
(SELECT t2.qte_id, t2.seq_no t2_seq_no, t1.seq_no t1_seq_no, cmmt_curr_amt, LAG(cmmt_curr_amt,1,0) OVER (PARTITION BY t2.qte_id ORDER BY t2.seq_no) cmmt_curr_lag
FROM table1 t1, table2 t2
WHERE t2.qte_id = t1.qte_id (+)
AND t2.seq_no = t1.seq_no(+)
ORDER BY 1,2
WHERE t1_seq_no IS NOT NULL
ORDER BY 1,2
QTE_ID T2_SEQ_NO DIFF
1435177 2 0
1435177 5 0
1435177 7 0
1435177 8 0
1435177 12 0
1435177 14 0 -
SQL Gurus : Need Help in building SQL query
SQL Gurus,
Need your expertise to solve my below problem:
- I have a column that had comma separated data, basically there are the levels in a hierarchy. eg The same column could have the following data:
Row 1: R1L1, R1L2, R1L3
Row 2: R2L1, R2L2
Row 3: R3L1, R3L2, R3L3, R3L4
For assumption purpose lets assume that there are maximum 5 Levels
I want to put this data from this column into another table which holds the levels. I am expecting the output in another table as follows:
Col1____Col2 ____Col3____Col4____Col5
Row 1: R1L1___R1L2____R1L3____null_____null
Row 2: R2L1___R2L2____null_____null_____null
Row 3: R3L1___R3L2____R3L3____R3L4___null
How do i achieve this ? ie coverting the comma separated values in a column to separate columns. The # of values in each columns could be different as I have showb above
Regards,
pkwith t as (
select 'R1L1, R1L2, R1L3' c1 from dual union all
select 'R2L1, R2L2' c1 from dual union all
select 'R3L1, R3L2, R3L3, R3L4' c1 from dual
select substr(c1,instr(', ' || c1 || ', ',', ',1,mod(l,5) + 1),instr(', ' || c1 || ', ',', ',1,mod(l + 1,5) + 1) - instr(', ' || c1 || ', ',', ',1,mod(l,5) + 1) - 2) col1,
substr(c1,instr(', ' || c1 || ', ',', ',1,mod(l - 1,5) + 1),instr(', ' || c1 || ', ',', ',1,mod(l,5) + 1) - instr(', ' || c1 || ', ',', ',1,mod(l - 1,5) + 1) - 2) col2,
substr(c1,instr(', ' || c1 || ', ',', ',1,mod(l - 2,5) + 1),instr(', ' || c1 || ', ',', ',1,mod(l - 1,5) + 1) - instr(', ' || c1 || ', ',', ',1,mod(l - 2,5) + 1) - 2) col3,
substr(c1,instr(', ' || c1 || ', ',', ',1,mod(l - 3,5) + 1),instr(', ' || c1 || ', ',', ',1,mod(l - 2,5) + 1) - instr(', ' || c1 || ', ',', ',1,mod(l - 3,5) + 1) - 2) col4,
substr(c1,instr(', ' || c1 || ', ',', ',1,mod(l - 4,5) + 1),instr(', ' || c1 || ', ',', ',1,mod(l - 3,5) + 1) - instr(', ' || c1 || ', ',', ',1,mod(l - 4,5) + 1) - 2) col5
from (
select c1,
length(c1) - length(replace(c1,',')) + 5 l
from t
COL1 COL2 COL3 COL4 COL5
R1L3 R1L2 R1L1
R2L2 R2L1
R3L4 R3L3 R3L2 R3L1
SQL> SY. -
Hi All,
I have belwo two record values.
select 1 as seq_no,'test1' as data_set from dual
union
select 1,'12test' from dual
union
select 2,'abcd' from dual
union
select 2,'ilm' from dual
union
select 2,'12test444' from dual
here i need to extract the below o/p from from the above dataset
1,12test
1,test1
2,12test444
select 1 as seq_no,'test1' as data_set from dual
union
select 1,'12test' from dual
union
select 2,'abcd' from dual
union
select 2,'ilm' from dual
here i need to extract the below o/p from from the above dataset
1,12test
1,test1
2,abcd
2,ilm
The logic behind the above two types of o/p is
if the search string 'test' is present in any data set (data set is defined by same seq_no values) then print the whole row containing the search string. As in the first record value data set with seq_val 1 and 2 both have test string 'test' , o/p is all the rows contating the search string 'test'
If the search string 'test' is not present in any data set (data set is defined by same seq_no values) then print all other rows not containing the search string. As in the second record value data set with seq_val 2 both doesn't have test string 'test' , o/p is all the rows not contating the search string 'test' in data test with seq_val 1as well as all the rows contating the search string 'test' in data set with seq_val 2
Hope i could explain my o/p logic and i need to perform this in a sql query.
Waiting for your responses.
Thanks in advance.Hi,
Here's one way:
WITH got_rnk AS
SELECT seq_no, data_set
, DENSE_RANK () OVER ( PARTITION BY seq_no
ORDER BY CASE
WHEN INSTR (data_set, 'test') > 0
THEN 1
ELSE 2
END
) AS rnk
FROM table_x
SELECT seq_no, data_set
FROM got_rnk
WHERE rnk = 1
;The CASE expression returns 1 if data_set contains 'test', and it returns 2 if it does not. Let's call this number x.
You're not really interested in x itself. Rather, you want all the rows that have the lowest value of x among rows with the same seq_no. That is, if any row with a given_seq_num has x=1, then you want all rows with that seq_no and x=1, but it the lowest x for the a seq_no is 2, then you want the rows with x=2 instead.
DENSE_RANK returns the the number 1 if the given riow is the lowest (or tied for the lowest) in its partition, so if the are any rows with x=1 in the group, rnk=1 will correspond to x=1. But if all the rows with the same seq_no have x=2, then rnk=1 will correspond to x=2. -
Hi All,
Could you please help me out the below SQL query tuning .
Temp table is having 1 Million records
Master table is having 60 Million records
Query :
SELECT B.*,U.ID, SD, LE, LAE
FROM client.Temp B, client.Master
U WHERE U.policyno = B.policyno
AND B.UPFLAG = 0
1. Indexes are created on both email columns and Upflag for both tables.
2. Gathered DBMS Stats for MASTER Table
Data is loading 100k/hour on production .When your query takes too long ...
When your query takes too long ...
HOW TO: Post a SQL statement tuning request - template posting
HOW TO: Post a SQL statement tuning request - template posting -
Sql query need for date format''Mon 23 Apr 16:45 pm'
i need SQL query to print date like 'Mon 23 Apr 16:45 pm' format
SQL> select to_char(sysdate,'Dy fmddfm Mon hh24:mi pm','nls_date_language=american') from dual
2 /
TO_CHAR(SYSDATE,'DY
Fri 27 Apr 13:04 pm
1 rij is geselecteerd.Regards,
Rob. -
Simplify SQL query - need suggestions
Hi,
I have a table "Product" in my Database , which i am using to create reports in OBIEE. The table has five cols : ID, Version, Date, ItemName, ItemRate . It is partitioned on Date col . The table has many rows and I want to hit Date partition to improve performance.I take Date as input from user by Date Prompt.
The primary key is ID+Version+ItemName
I want to get a table which contains Date, ItemName,ItemRate, ID for each ID with max(Version). This table I will join with another table in Oracle BI Answers to generate reports. If an ID has many versions, I get max version value and then return ID,ItemName,ItemRate,Date corresponding to that Verion value.
What is the best way to achieve this, should I define view in my physical layer which contains sql query for simplified table so that it will make my task of generating reports easier by having asimplified table in Oracle BI Answers ? ?
Please ask if any clarification is needed ....
ThanksThere are couple of ways to handle your requirements. Try this:
When table is partitioned we have to use fragmentation option using LTS->Proparties->Content tab specify the condition at
Fragmentation content:
and
Check 'This source should...'
For Max(version): Use repository variable for getting max(version) and filter using Where clause option in Content tab.
Let me know updates -
Passing parameter to a SQL query - Please help
Hi All,
I am new to JDBC. I have been trying to pass an external variable to an SQL Query.
The query is
String username1="le";
PreparedStatement pstmt = null;
pstmt = c.prepareStatement("select * from users where USER_NAME like '%?%'");
pstmt.setString(1, username1);
pstmt.executeQuery();
ResultSet rs = pstmt.getResultSet();
I am trying to retrieve values from the users table where the USER_NAME column value that is a String contains the supplied value username1.
I am using the question mark (?) character to pass the value from the variable username1. I am also using the '%' substitution character which matches for any number of characters. So, the above query should retrieve rows where the USER_NAME is something like "charles","leander","Elena" etc.( that contains "le")
I am getting the error:
SQLException: java.sql.SQLException: ORA-01006: bind variable does not exist
I changed the query to
PreparedStatement pstmt = null;
pstmt = c.prepareStatement("select * from users where USER_NAME like '% " + username1 + "%'");
//pstmt.setString(1, username1);
pstmt.executeQuery();
This time , it is not giving the error and retrieving properly.
But I want to use the original query and use the "pstmt.setString(1, username1); " . Is there any way of achieving this?
Please help.
Cheers,
charles_amhi,
try this...
String username1="%le%";
pstmt = c.prepareStatement("select * from users where USER_NAME like ?")
pstmt.setString(1,username1);
cheers,
rpk -
List the count of each schema objects.. schema wise sql query needed
Hi Friends,
i need a sql query which has to list the schema name along with the count of schema objects like tables,views,triggers.... order by schemaname
Regards,
DBHi
You can try this option if you use 11g .
Get all the object types in your db.
SELECT DISTINCT object_type
FROM dba_objects;Then include all the object types in to the below query.
select *
from (select owner, object_type, 1 CNT
from dba_objects ) e
pivot( sum(CNT) for object_type in
( 'INDEX','TYPE','VIEW','LIBRARY','TRIGGER','DIRECTORY','PACKAGE','QUEUE','PACKAGE BODY','TABLE PARTITION','PROCEDURE',
'WINDOW','CLUSTER','LOB','FUNCTION','CONSUMER GROUP','CONTEXT','RULE','XML SCHEMA','SEQUENCE','INDEX PARTITION','OPERATOR',
'EVALUATION CONTEXT','SCHEDULE','JOB','SCHEDULER GROUP','LOB PARTITION','JOB CLASS','INDEXTYPE','TABLE','TYPE BODY','RESOURCE PLAN',
'TABLE SUBPARTITION','UNDEFINED','DESTINATION','SYNONYM','EDITION','PROGRAM','RULE SET' ) )
order by owner;Cheers
Kanchana -
Sql query needed to verify force logging
Hi.
Does anyone out there have SQL query we need to run in order to see if our db is working in force logging mode?
Thanks.
DAThe FORCE_LOGGING column of v$database view can be queried to verify that the database is in FORCE LOGGING mode. Similarly, the FORCE_LOGGING column of dba_tablespace view provides the same information for each tablespace.
Kamran Agayev A. (10g OCP)
http://kamranagayev.wordpress.com
Maybe you are looking for
-
Hi Ppl, I am using REUSE_ALV_COMMENTARY_WRITE to display top of page in ALV. The issue is i want to restrict the top-of-page height. As of now if i have 10 lines to print...the top-of-page comes with 10 lines in display. But i want some (say 4 or 5)
-
Please Help - I want to use my iPod : (
Here is the problem: A few months ago my iTunes no longer recognized my pod even though my computer did. I went through Apple's suggestions, reinstalling software/iTunes to no avail. I reset my pod to factory settings, but it would still not be recog
-
"Page cannot be displayed" error in EBS R12
Hi All, We implemented EBS R12 with 2 Application Node, 2 CM nodes and 2 DB Nodes(RAC). We have also setup load balancer at the application level. We have enabled HTTPS at the load balancer level. Our application works perfectly fine except some of t
-
Clean install of Mavericks, now cannot access Time Machine backups
I just performed a clean install of Mavericks (10.9.1), but now I cannot access my previous backups under Mountain Lion (10.8.5). The new installation recognizes the TM disk just fine, and I can enter TM, but all of my old backups are blacked out. In
-
Report with all Data Targets in Production and Record Count
Hi, I am planning to create new report to handle some production maintenance work. How do I create a report with list of each ODS and Cube and count of Active record count? Can I use any report in BW statistics and modify based on my requirements? An