Please solve the query in a single query
1. display names of scott's collegue who earn more than scott
using the emp table of scott schema
As it's homework, we could always post you a really poor example of code like this:
SQL> ed
Wrote file afiedt.buf
1 select *
2 from emp
3 where (1,empno) in (
4 select case when sal > (select sal from emp where ename = 'SCOTT') then 1 else 0 end as flag, empno
5 from emp
6* )
SQL> /
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7839 KING PRESIDENT 17/11/1981 00:00:00 5000 10But it would be better if you gave us an example of what you have done yourself, before we show you where you have gone wrong and how it can be improved.
Similar Messages
-
How can I get the same result using single query?
There are 3 tables
1) tool_desc -
a master table for storing tool records,
columns tool_no, tool_chg,
# of records = 1.5 Millon
2) step_desc -
a master table for storing plan wise step records,
columns plan_id, step_key,
# of records = 3700 Million
3) step_tool - a transaction table storing tools to the steps,
columns plan_id, step_key, tool_no, tool_chg
For each step in the step_desc table, I need to randomly fetch 1 to 50 tools from tool_desc and insert them into step_tool table.
Using PL/SQL block, it is like the following -
begin
for x in (select plan_id, step_key from step_desc) loop
insert into step_tool(
plan_id,
step_key,
tool_no,
tool_chg)
select
plan_id,
x.step_key,
tool_no,
tool_chg
from
tool sample(0.1)
where
rownum <= trunc(dbms_random.value(1,51))
commit;
end loop;
end;
I need to do the same using a single query so that I can use the CTAS (create table as select) statement and load the data as a bulk.
Can I do that?If they have parent child releation, you can use connect by prior clause,
-
I have a problem in the answers to the questions on my account I can not buy anything, please solve the problem
You are not addressing Apple here. And your post is a bit confusing. See Klaus's answer in this thread:
https://discussions.apple.com/thread/5228474?tstart=0 -
Sir,
I bought iphone 4 in US.last 6 month me and other person not able to listen properly the voice because the voice is cracking.i have called earlier about the above problem and they said to upload the new verson 6.1.3 and it will be done but after loading this version still i am facing the same problem.so ,i would like to request you that please solve the above problem as soon as you can.I will be thankful to you.i love my apple Iphone.
waiting for your earliest reply.
thanks
Rajeev GuptaHello sir
As you know about my iPhone 4 which has a problem of voice cracking so I would like to replace to other phone like IPhone 5s.I will pay the replacement charges immediately.i am reaching miami on 19th of janvary 2014 so I would like to request you please arrange my appointment on the Apple store,dadeland mall ,miami at 15.00pm as I will reach miami at 13.00pm and my flight to India at 19.00pm.
Last time you told to replace at miami on 26th of September but without oppoimtment they have not entertained me.so I would like to request you that please arrange my appointment this time
I will be thankful to you
Rajeev Gupta -
My AppStore can not download app. He said need to fill in credit card. But I got no credit card. And how I fill in? Please solve the problem. Thank you.
<Email Edited by Host>Hi Steve,
If you don't have a credit card for the billing information you may be able to use a gift card or another form of payment.
Please check out this article for details.
Why can’t I select None when I edit my Apple ID payment information? - Apple Support
Best,
Nubz -
How to make the query in one single query? No Union please....
Hi,
I have sets of around 18 queries which is finding counts in many scenarios. I wanted to have a single query for this. which diplays the result in a single row.Is there a way , I heared analytical functions are good options ,but I am new to Oracle . Please help me.
select count(*) total_count from emp; --100
select coun(*) MGR_count from emp where job='MGR'-- 10
select count(*) dept_count from emp where deptno in(10 ,20)-- 75
output..
TOTAL_COUNT MGR_COUNT DEPT_COUNT
100 10 75
ThanksThis:
select count(*) total_Count
,count(decode(job,'MGR',1,null)) mgr_count
,count(case when deptno in (10,20) then
1
else
null
end
) dept_count
from emp;
untested -
Please Slove the Query as below:
T1
| A1 | A2 |
| TRUE | FALSE |
| FALSE | TRUE |
| TRUE | TRUE |
| FALSE | TRUE |
Table Name is: T1 and it is having 2 columns A1 and A2.
Question is:
Using a simple SQL query try to get the total number of "TRUE" in the Table T1. Don't use any PL/SQL command,
just use simple SQL command.
Please write the full query.
Manojit.select (Nvl(a.cnt_a1,0) + Nvl(b.cnt_a2,0)
from (select count(1) CNT_A1 from t1 where a1 = 'TRUE') A
(select count(1) CNT_A2 from t1 where as = 'TRUE') B
Please Slove the Query as below:
T1
| A1 | A2 |
| TRUE | FALSE |
| FALSE | TRUE |
| TRUE | TRUE |
| FALSE | TRUE |
Table Name is: T1 and it is having 2 columns A1 and A2.
Question is:
Using a simple SQL query try to get the total number of "TRUE" in the Table T1. Don't use any PL/SQL command,
just use simple SQL command.
Please write the full query.
Manojit. -
How can I update the table with a single query for...
I have a table with columns C1 and C2.
C1 C2
A1 null
A1 null
A1 null
A1 null
A2 null
A2 null
A2 null
A3 null
A4 null
A4 null
I want to update my table with a single query so that I would have data like
C1 C2
A1 1
A1 2
A1 3
A1 4
A2 1
A2 2
A2 3
A3 1
A4 1
A4 2
The updated column C2 has the values like serial no grouped on the column C1.SQL> create table mytable
2 ( c1 varchar2(2)
3 , c2 number(2)
4 )
5 /
Tabel is aangemaakt.
SQL> insert into mytable (c1)
2 select 'A1' from dual union all
3 select 'A1' from dual union all
4 select 'A1' from dual union all
5 select 'A1' from dual union all
6 select 'A2' from dual union all
7 select 'A2' from dual union all
8 select 'A2' from dual union all
9 select 'A3' from dual union all
10 select 'A4' from dual union all
11 select 'A4' from dual
12 /
10 rijen zijn aangemaakt.
SQL> select * from mytable
2 /
C1 C2
A1
A1
A1
A1
A2
A2
A2
A3
A4
A4
10 rijen zijn geselecteerd.
SQL> merge into mytable t1
2 using (select c1
3 , row_number() over (partition by c1 order by null) rn
4 , rowid rid
5 from mytable
6 ) t2
7 on (t1.rowid = t2.rid)
8 when matched then
9 update set c2 = rn
10 when not matched then
11 insert values (null,null)
12 /
10 rijen zijn samengevoegd.
SQL> select * from mytable
2 /
C1 C2
A1 1
A1 2
A1 3
A1 4
A2 1
A2 2
A2 3
A3 1
A4 1
A4 2
10 rijen zijn geselecteerd.Regards,
Rob. -
How to read the child elements in single query
Hi
How to read the child elements under 'alternateIdentifiers' and 'matchEntityBasic' in a single query followiing xml content.xml content is of xmltype
I/p doc
<UPDATES>
<matchEntity>
<sourceUpdateId>SAMSUNG</sourceUpdateId>
<matchEntityId>861873</matchEntityId>
<alternateIdentifiers>
<sourceUpdateId>SAMSUNG</sourceUpdateId>
<schemeCode>SMG</schemeCode>
<effectiveDate>2012-01-16</effectiveDate>
</alternateIdentifiers>
<alternateIdentifiers>
<sourceUpdateId>SAMSUNG</sourceUpdateId>
<schemeCode>TEBBGL</schemeCode>
<effectiveDate>2012-01-16</effectiveDate>
</alternateIdentifiers>
<matchEntityBasic>
<sourceUpdateId>SAMSUNG</sourceUpdateId>
<marketExchangeCode>XASE</marketExchangeCode>
</matchEntityBasic>
</matchEntity>
</UPDATES>
o/p
sourceUpdateId schemeCode effectiveDate marketExchangeCode
SAMSUNG SMG 2012-01-16 XASE
SAMSUNG TEBBGL 2012-01-16
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
i tried the query but not working
SELECT sourceUpdateId ,schemeCode ,effectiveDate ,marketExchangeCode FROM message pl,XMLTABLE ('/UPDATES/matchEntity/alternateIdentifiers'
PASSING pl.messagetext
COLUMNS sourceUpdateId VARCHAR2 (20) PATH sourceUpdateId,
schemeCode VARCHAR2 (20) PATH 'schemeCode',
effectiveDate DATE PATH 'effectiveDate',
marketExchangeCode VARCHAR2 (20) PATH './matchEntityBasic/marketExchangeCode'
) x
iam not retriving marketExchangeCode with the following query
marketExchangeCode VARCHAR2 (20) PATH './matchEntityBasic/marketExchangeCode'
thanksThe problem is that "matchEntityBasic" is not a child of "alternateIdentifiers", so this :
./matchEntityBasic/marketExchangeCodepoints to nothing.
To display both values in the same query, you'll need a two-level approach.
For example :
SQL> SELECT x2.sourceUpdateId
2 , x2.schemeCode
3 , x2.effectiveDate
4 , x1.marketExchangeCode
5 FROM message pl
6 , XMLTable(
7 '/UPDATES/matchEntity'
8 passing pl.messagetext
9 columns marketExchangeCode VARCHAR2(20) PATH 'matchEntityBasic/marketExchangeCode'
10 , alternateIds XMLType PATH 'alternateIdentifiers'
11 ) x1
12 , XMLTable(
13 '/alternateIdentifiers'
14 passing x1.alternateIds
15 columns sourceUpdateId VARCHAR2(20) PATH 'sourceUpdateId'
16 , schemeCode VARCHAR2(20) PATH 'schemeCode'
17 , effectiveDate DATE PATH 'effectiveDate'
18 ) x2
19 ;
SOURCEUPDATEID SCHEMECODE EFFECTIVEDATE MARKETEXCHANGECODE
SAMSUNG SMG 16/01/2012 XASE
SAMSUNG TEBBGL 16/01/2012 XASE
Or the shorter version :
SQL> SELECT x.sourceUpdateId
2 , x.schemeCode
3 , x.effectiveDate
4 , x.marketExchangeCode
5 FROM message pl
6 , XMLTable(
7 'for $i in /UPDATES/matchEntity
8 return
9 for $j in $i/alternateIdentifiers
10 return element r { $j/child::*, $i/matchEntityBasic/marketExchangeCode }'
11 passing pl.messagetext
12 columns sourceUpdateId VARCHAR2(20) PATH 'sourceUpdateId'
13 , schemeCode VARCHAR2(20) PATH 'schemeCode'
14 , effectiveDate DATE PATH 'effectiveDate'
15 , marketExchangeCode VARCHAR2(20) PATH 'marketExchangeCode'
16 ) x
17 ;
SOURCEUPDATEID SCHEMECODE EFFECTIVEDATE MARKETEXCHANGECODE
SAMSUNG SMG 16/01/2012 XASE
SAMSUNG TEBBGL 16/01/2012 XASE -
Hi,
I have a query which requires me to find the language that is known by only on programmer
PNAME PROF1 PROF2
anand pascal basic
altaf clipper cobol
juliana cobol dbase
kamala c dbase
mary c++ oracle
nelson cobol dbase
partick pascal clipper
qadir assembly c
ramesh pascal dbase
resecca basic cobol
remitha c assembly
revathi pascal basic
vijaya foxpro c
The answer to this query is
C++
foxpro
oracle.Hi APC,
SQL> SELECT prof, p_cnt FROM(
2 SELECT prof1 AS prof, count(pname) AS p_cnt
3 FROM user_lang
4 GROUP BY prof1
5 UNION
6 SELECT prof2 , count(pname)
7 FROM user_lang
8 GROUP BY prof2 )
9 WHERE p_cnt = 1;
PROF P_CNT
assembly 1
basic 1
c++ 1
clipper 1
foxpro 1
oracle 1
6 rows selected.You have to count AFTER the union... ;-)
Regards,
Gerd -
How can I get the avaiable datatypes using single query?
Is there any sql query to determine available datatypes along with their size lime in the current version of Oracle ?
If they have parent child releation, you can use connect by prior clause,
-
class Horseradish
//insert code here
protected HorseRadish(int x)
System.out.println("bok choy");
class Washabi extends HorseRadish{
public static void main(String[] args)
Wasabi w=new Wasabi();
which two,inserted independently at line 2,will allow the code to compile and produce the output "bok choy"?(choose two)
1. //just a comment
2. protected HorseRadish(){}
3.protected HorseRadish()
{this(42);}
4.protected HorseRadish() { new horseRadish(42);}
which two are the right options and why??
please answerbecause we want people to think for themselves rather
than spoonfeed them everything.
When you start spoonfeeding them, they'll never learn
to think on their feet and will forever come here
with every tiniest problem.Original:
public class Spoon {
public static Answer feed(Person me) {
/* Implementation */
}New:
protected class Spoon {
private static Answer feed(Person me) {
/* Implementation */
}Problem solved. -
===================================
Create failed for Database 'Qlao'. (Microsoft.SqlServer.Smo)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=10.50.1750.9+((dac_inplace_upgrade).101209-1051+)&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Create+Database&LinkId=20476
Program Location:
at Microsoft.SqlServer.Management.Smo.SqlSmoObject.CreateImpl()
at Microsoft.SqlServer.Management.Smo.Database.Create()
at Microsoft.SqlServer.Management.SqlManagerUI.CreateDatabaseData.DatabasePrototype.ApplyChanges(Control marshallingControl)
at Microsoft.SqlServer.Management.SqlManagerUI.CreateDatabase.DoPreProcessExecution(RunType runType, ExecutionMode& executionResult)
at Microsoft.SqlServer.Management.SqlMgmt.SqlMgmtTreeViewControl.DoPreProcessExecutionAndRunViews(RunType runType)
at Microsoft.SqlServer.Management.SqlMgmt.SqlMgmtTreeViewControl.ExecuteForSql(PreProcessExecutionInfo executionInfo, ExecutionMode& executionResult)
at Microsoft.SqlServer.Management.SqlMgmt.SqlMgmtTreeViewControl.Microsoft.SqlServer.Management.SqlMgmt.IExecutionAwareSqlControlCollection.PreProcessExecution(PreProcessExecutionInfo executionInfo, ExecutionMode& executionResult)
at Microsoft.SqlServer.Management.SqlMgmt.ViewSwitcherControlsManager.RunNow(RunType runType, Object sender)
===================================
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
Program Location:
at Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(String sqlCommand, ExecutionTypes executionType)
at Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(StringCollection sqlCommands, ExecutionTypes executionType)
at Microsoft.SqlServer.Management.Smo.ExecutionManager.ExecuteNonQuery(StringCollection queries)
at Microsoft.SqlServer.Management.Smo.SqlSmoObject.ExecuteNonQuery(StringCollection queries, Boolean includeDbContext)
at Microsoft.SqlServer.Management.Smo.SqlSmoObject.CreateImplFinish(StringCollection createQuery, ScriptingOptions so)
at Microsoft.SqlServer.Management.Smo.SqlSmoObject.CreateImpl()
===================================
CREATE DATABASE permission denied in database 'master'. (.Net SqlClient Data Provider)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=10.50.1617&EvtSrc=MSSQLServer&EvtID=262&LinkId=20476
Server Name: SLPSOFTSOLS1
Error Number: 262
Severity: 14
State: 1
Line Number: 1
Program Location:
at Microsoft.SqlServer.Management.Common.ConnectionManager.ExecuteTSql(ExecuteTSqlAction action, Object execObject, DataSet fillDataSet, Boolean catchException)
at Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(String sqlCommand, ExecutionTypes executionType)Hello,
This issue might be caused by the User Account Control (UAC) settings if we use Windows 7 or Windows Server2008, ect Operating System. Please also take a look at the following articles:
http://social.msdn.microsoft.com/Forums/sqlserver/en-US/28fee0ed-c7e2-40df-8f79-f513c9848f09/create-database-permission-denied-in-database-master-microsoft-sql-server-error-262?forum=sqltools
http://blogs.msdn.com/b/dparys/archive/2009/09/17/create-database-permission-denied-in-database-master-my-fix.aspx
Regards,
Elvis Long
TechNet Community Support -
Please solve the code inpsector error: Sequential read access possible
Hi,
i am getting code inspector warning message . could u please try to provide the solution for that warning message.
code inspector warning message is : Sequential read access possible for a hashed table
My statment : read table <lt_product_mbr> with table key (ujr0_c_member_id) = <l_product> assigning <ls_product_mbr>.
i declared <LT_PRODUCT_MBR> TYPE ANY TABLE.
Eventough i delared it as a type hashed or sorted . it is giving same warning message.
Regards
KotiHi Koti,
you specified the key field dynamically (variable in brackets). That means
it can not be checked statically whether the table key of the hashed table
is used or not since this is only clear at run time.
If you use the dynamic key specification
read table <lt_product_mbr> with table key (ujr0_c_member_id) = <l_product> assigning <ls_product_mbr>.
and not the direct key:
read table <lt_product_mbr> with table key field = <l_product> assigning <ls_product_mbr>.
the CI will warn you that you may end up with a sequential red (if not the table key of the hashed table
is used in the variable at run time.
Kind regards,
Hermann -
Apple, please solve the -50 and 1418 error issue
Dear Apple,
I have read during hours this forum and also posting my own experiences. Does anyone have a solution to these -50 and 1418 errors? Apple has exchanged my 2G Shuffle twice already, but no solution. I strongly suspect it to be an iTunes software issue or incompatibility, since the Shuffle is being recognized perfectly under Windows XP explorer and I can copy and read any files from the computer to the shuffle and vice versa. But as soon as I start iTunes, the Shuffle disappears in the Windows explorer, is being recognized in iTunes but then it stops: error -50, "The disk cannot be written to or read from", error 1418 when trying to restore, no music synching and no restoring possible.
HELP PLEASE
Windows XP Prohttp://docs.info.apple.com/article.html?artnum=304508
Maybe you are looking for
-
I have three different libraries. How can I combine them?
Downloading more music onto my Mac, but they show up in different libraries on my ipod. Is there a way to combine the libraries? Thanks
-
MacBook (Mid 2010) Running Extremely Slow
ATTENTION OWNERS OF MACBOOKS OR APPLE COMPUTERS: I have a question, my MacBook (year 2010) has not only been running slower than a turtle since I upgraded to the newest version but I now can't control my volume or brightness with my keyboard anymore.
-
I just changed my Apple ID and I verified it but when I try to login it says my Apple ID is not verified. Now I can't access my iTunes account at all. How can I fix this?
-
Training nd Event Management Question
I have an event scheduled in the past period in T&E Management. I am still able to book attandees to this event .. I think this is not right. However, I would like to know if there is any follow up action I need to do on this event so that the event
-
Hi Experts, Can i know from where can I get the field information of Attendance of the entire month from 1st until 30/31st of the month. If the employee is General absent/ LOP it should be displayed as A, Present it should be displayed as P