Simple SQL query statement is needed
I need a simple SQL query to fetch records which is existed in all the departments.
for example: i want to list the employees which are existed in each and every department.. not sure how should i get those.. will anyone help me please.. thanks in advance
I think it would be wise to go to the following training:
Oracle Database <version> : Introduction to SQL
You will get the information you are looking for in five days. You can go find a tutorial on ANSI SQL, as advised by this board for free, to fix your immediate problem with a simple query. But, I personally recommend a more formal class specific to Oracle, as you will also get information about PL/SQL, and you get the benefit with working with other DBA/programmers when you are learning. This will solve your immediate issue, and any future issues with the language.
You can find it in the Education section of the Oracle website.
Similar Messages
-
Simple SQL Query and Parameters and LOV
Newbie and trying to work thru building a simple sql query with a single table query and use a parameter and lov.
Can anyone point me to an example.
simple query:
select cust_id, name_desc, name_add1, name_add2, name_city
from customer_table
where cust_id = :cust_parm
This works in straight sql and in the query builder by prompting for the customer ID. When building a parameter using LOV or search, it doesn't seem to detect the variable.
Thanks..
DDIf you are using version 11g, then as soon as you save the query in the data model, it should notice the parameter and ask if you want to add the parameter to the data model. What version of BIP are you using?
What happens if you exclude the parameter from the query and simply hard-code the criteria? Can you generate XML data?
From your wording, it sounds like you're trying to create a parameter from the LOV dialog. LOVs and parameters are totally distinct. After each are created separately, then you configure the parameter to use the LOV. -
Simple SQL query SQL developer takes it, The wizzard of XE does not
Hello everybody
I wrote this simple query which SQL developer runs fine, but when I try to launch a Report based on this sql query it tells me invalid sql statement. That is true, it may be invalid because this IF clause in there..but SQL developer seems to be very tolerant or understands more...
the reason I wrote that is because obviously if there are no bosses, ie = 0 then i would get an error when dividing it by 0, so I put that 0 just to select the good ones
if count (bosses) >0
select company, postcode,
sum( bosses/staff)
from evaluation
group by company, postcode
Thank you very much
Alvarooh yes (blushed in shame as how dumb i looked like) i knew about the denominator 0 and infinite as as result i just didnt notice my zero was on the numerator :(
however, i run the query and i got this message in sql developer
Error starting at line 1 in command:
select company, postcode,
case when staff != 0 then sum( bosses/staff) end
from evaluation
group by company, postcode
Error at Command Line:2 Column:10
Error report:
SQL Error: ORA-00979: not a GROUP BY expression
00979. 00000 - "not a GROUP BY expression"
*Cause:
*Action: -
Your estimated performance of a very simple SQL query
Hi there..
Sometimes it seems hard to find answers for the most simple questions so I hope you can help me and be overbearing ;)
I am going to have a table with a few million records in it, 30-40 columns of which 80% has data, indexes on maybe 10 columns (certainly the columns I am querying), less than ten thousand new records a day with a variety of different column values and using Oracle 10 or 11.
I am going to be running a single SQL SELECT statement quite regularily against these records to retrieve all records whose value of a single column is the same (and specified in my WHERE clause)
It will be a query like this; SELECT * FROM person where city = 'Amsterdam' AND
The column 'city' will have a simple index on it. 4-8 records will have the same value (e.g. there will only be up to 8 rows where city is 'Amsterdam' in the above example) which means that with 5 million records I will probably have between 625,000 and 1,250,000 "sets" that I am querying and retrieving per SQL. Thed atatype could be varchar or number - not sure yet.
I will retrieve the same data a lot but generally also access all the other data on a regular basis.
How should I expect this to perform? Always fast I imagine because will there will be any table scans do we think? I don't have to think about partitioning of too regular statistic calculation or anything? Anything to watch out for?
Any feedback would be greatly appreciated.
Thanks a lot in advance.
DanielIt's impossible to tell without seeing a true structure and indexes etc.
It sounds ok at a first read. High selectivity, low cardinality, low skewing. Obviously, ensuring stats are up to date on a reasonably regular basis is a good idea, especially with 10,000+ records added daily. I would expect it to perform ok. -
Exu00E9cute an SQL Query statement.
Hi,
Can someone tel me if exist a transaction code who can help me to execute an SQL query (far than my report), either UPDATE or SELECT statement ?
Thanks in advance.
MustaphaHi Shiva,
I want to execute a SQL query like : Select vbeln from vbpa where vbeln = '00000545645'. and show to me a list (the result) in the same page.
P.S : I want to test a join query without going through the debugging.
thank you.
Best regards
Mustapha -
Hi,
I would like to know how this type of query is processed internally in Oracle
SQL> select * from ( select 1 from dual, ( select 2 from dual ) g );
1
1
SQL> select * from ( select 1 from dual, select 2 from dual );
select * from ( select 1 from dual, select 2 from dual )
ERROR at line 1:
ORA-00903: invalid table nameWhy would 1 2 not be printed in result?
Thanksuser1980 wrote:
Hi,
I would like to know how this type of query is processed internally in Oracle
SQL> select * from ( select 1 from dual, ( select 2 from dual ) g );
1
1
SQL> select * from ( select 1 from dual, select 2 from dual );
select * from ( select 1 from dual, select 2 from dual )
ERROR at line 1:
ORA-00903: invalid table nameWhy would 1 2 not be printed in result?
ThanksJust look at what you are selecting from...
SQL> select 1 from dual, select 2 from dual;
select 1 from dual, select 2 from dual
ERROR at line 1:
ORA-00903: invalid table name
SQL>it's not valid syntax for an SQL select statement so you can't use it as an inline view.
If you are select from something, then that something has to be a valid view or table. -
How to insert a sql query statement in the table
I have a stored procedure which has different insert,update statements on different tables. I am writing a trigger on these tables such that when the record is updated or inserted in these tables a trigger should fire and should write the old value,new value and the query (insert or update) that caused the trigger to fire in the seperate table. Is there any way to find out the exact query statement that fired the trigger?
Rather than inventing your own demi-donkeyed solution I recommend you consider using Oracle's Fine-Grained Auditing which does precisely this.
Cheers, APC -
How to get the SQL Query statement of a Search Form ?
Hi all,
We have a requirement to send the query result of an ADF Search Form into report application (Crystal rpt).
Crystal can accept data source as query statement. SO I think of getting the exact query statement "generated" by the ADF Search form and send it to crystal.
Is this possible ?
Thank you very much,
xtantoTry the various get methods of the viewObject such as getQuery:
http://www.oracle.com/webapps/online-help/jdeveloper/10.1.2/state/content/navId.4/navSetId._/vtAnchor.getQuery%28%29/vtTopicFile.bc4jjavadoc%7Crt%7Coracle%7Cjbo%7CViewObject%7Ehtml/ -
SQL query statement for stored procedure / function listing ...
Hi everyone,
Is there a SQL query to list all the stored procedures and functions of an user in an Oracle 8 database?
I have this idea:
select * from USER_SOURCE where TYPE = 'PROCEDURE' or TYPE = 'FUNCTION'
but I am not too sure whether this is correct.
Thanks in advance,
EricYeah
I agree with you Garcia , my above posting was a correction to the query mentioned in the question only.
you are correct
If you only want the name of the object,
SELECT Object_Name from User_Objects where object_type in ( 'PROCEDURE' ,'FUNCTION');
is much faster than Selecting (distinct) from User_Source. -
Help! with sql:query statement
Using JSTL, I am trying to select two tables from two different database. The tables do not contain the same information but just happen to have the same name "desc" . I have something like this.
<sql:query var="result">
Select trim(DATA.desc), trim(TEXT.desc) from DATA, TEXT
</sql:query>
<c:forEach items="${result.rows}" var="row1">
<c:out value="${row1}"/>
</c:forEach>It displays the second table which is TEXT.desc and ignores the other DATA.desc.
How do I display them both?Is there a way to query it and output the result in an array?Sure - you can use the call to rowsByIndex which returns a 2d array:
I think the following should work
<sql:query var="result">
Select trim(DATA.desc) as dataDesc, trim(TEXT.desc) as textDesc from DATA, TEXT
</sql:query>
<c:forEach items="${result.rowsByIndex}" var="row1">
<c:out value="${row1[0]}"/>. <c:out value="${row1[1]}"/>
</c:forEach>However the previous code should have worked. I would double check your data and query that it is returning the data you think it is.
Cheers,
evnafets -
I have an interesting problem and wondering how I can get this result in a single SQL query:
Here is table emp has data with a row for every year since the employee joined with the salary paid that particular year with following columns:
emp (
id varchar2(10),
name varchar2(25),
interested_year date,
salarypaid number(10)
I would like to print the results as follows:
id name previousyear_salarypaid currentyear_salarypaid
x xxxxx xxxxxx xxxxx
Is this possible to do? I have tried to simplify my actual problem so I hope I have included all necessary details.Just to clarify, the columns mentioned in the results are
previousyear_salarypaid is nothing but
salarypaid where interested_year = '2007'
currentyear_salarypaid is nothing but
salarypaid where interested_year = '2006' -
hi,
I have two tables.
tbl1
col1 col2
a 2
a 3
b 4
tbl1
col1 col2
a 3
b 5
i need to update table1 records with the value present in table. means after updation table1 record should be
tbl1
col1 col2
a 3
a 3
b 5
its pretty simple but i am not getting the answer. Thnks in advance for help.
AshishA quick, yet dirty solution:
Update
tbl1 t1
Set
t1.col2 =
case
when (select t2.col2 from tbl2 t2 where t1.col1=t2.col1) is null
then (select max(t3.col2) from tbl1 t3 where t1.col1=t3.col1)
else (select t2.col2 from tbl2 t2 where t1.col1=t2.col1)
end; -
Simple SQL query..need help
Hi All,
I have a requirement not to show the row, if all columns value is zero. Could someone help me how to do it?
For example:
A B C D E
1 1 5 1 2
1 0 5 0 2
0 9 7 1 0
0 0 0 0 0
From the above example the only last row should not be shown, because all columns value is zero.
Thanks in advance.Another way:
with abc as (select 1 a, 1 b, 5 c, 1 d, 2 e from dual union all
select 1 a, 0 b, 5 c, 0 d, 2 e from dual union all
select 0 a, 9 b, 7 c, 1 d, 0 e from dual union all
select 0 a, 0 b, 0 c, 0 d, 0 e from dual union all
select null a, 0 b, 0 c, 0 d, 0 e from dual)
select a, b, c, d, e
from abc
where (nvl(a, 0), nvl(b, 0), nvl(c, 0), nvl(d, 0), nvl(e, 0)) not in (select 0,0,0,0,0 from dual);
A B C D E
1 1 5 1 2
1 0 5 0 2
0 9 7 1 0 -
Execute simple SQL query on Java
Hello,
I am a newbie on ADF, I am a web developer used to work with EJBs, WebServices, Servlets and this stuff... But now I am on a project that uses ADF.
My opinion, I don´t like this kind of development, drag and drop, I prefer to code on :) but, I need to work.
I am developing a utility class that needs to run some SQL statements and send an email.
I tried to work with the conventional @Resource (name...) Datasource ds; and did not worked, because it does not injected the object.
I tried to create a java implementation of my application module, instanciate it and get a ViewObject that I created to do a select statement, and the ViewObject comes null...
I just wanna do a simple query... just it, using simple java for web I would have already done it... How is the best way to do it?
Thanks.ApplicationModuleImpl am = getApplicationModuleByName("AppModuleDataControl")
DBTransaction dbt = am.getDBTransaction();
CallableStatement cs = dbt.createCallableStatement(query, .......
You can get ApplicationModule by this code. In this case there should be some binding related to this AM in pageDef. Input parameter "name" should be datacontrol name;
public static ApplicationModuleImpl getApplicationModuleByName(String name) {
try {
BindingContext bc = (BindingContext)resolveExpression("#{data}");
DCDataControl dc = bc.findDataControl(name);
return (ApplicationModuleImpl)dc.getDataProvider();
} catch (Exception e) {
l.error(e);
return null;
public static Object resolveExpression(String expression) {
l.debug("expression: " + expression);
FacesContext fctx = FacesContext.getCurrentInstance();
ELContext elctx = fctx.getELContext();
ExpressionFactory exprFactory =
fctx.getApplication().getExpressionFactory();
ValueExpression ve =
exprFactory.createValueExpression(elctx, expression, Object.class);
Object value = ve.getValue(elctx);
return value;
} -
Probably a simple SQL Query - Newbie
I want to select entries from a table that has 2 columns where the first column value is contained within the 2 column....Does that make sense?
The first is a varchar that contains a value for a customer. The second is a varchar that contains a a textual description of a problem the customer has. My problem is that I only want to select the entries in the table where the second column contains a description that includes the first column value.
eg. I want to select rows that have the following condition:
column1 has value of "customer1"
column2 has a value of "an error was reported by customer1 on service blah"
but not these
column1 has value of "customer1"
column2 has a value of "an error was reported by customer2 on service blah"
This is probably a simple question but I've spent time looking at how to do it and can't seem to manage...any help would be appreciated....ThanksHi Barbara,
I've never used the CONTAINS operator before. I compared the use in this situation to the other methods and found the others to be FAR less resource intensive, despite working on unindexed columns, as I demonstrate below.
It would seem that CONTAINS is unsuited to this type of simple query. Can you shed any light on this, from the perspective of somebody who has used it before? Is this type of performance penalty normal? If so, it could seem that CONTAINS is fairly useless next to LIKE.
[email protected]> desc test;
Name Null? Type
COLUMN1 VARCHAR2(20)
COLUMN2 VARCHAR2(100)
[email protected]> select count(*) from test;
COUNT(*)
10000
Elapsed: 00:00:00.00
[email protected]> select * from test where instr(column2, column1) > 0;
10000 rows selected.
Elapsed: 00:00:00.18
Execution Plan
0 SELECT STATEMENT Optimizer=ALL_ROWS (Cost=23 Card=8328 Bytes=532992)
1 0 TABLE ACCESS (FULL) OF 'TEST' (TABLE) (Cost=23 Card=8328 Bytes=532992)
Statistics
5 recursive calls
0 db block gets
821 consistent gets
0 physical reads
0 redo size
702263 bytes sent via SQL*Net to client
7838 bytes received via SQL*Net from client
668 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
10000 rows processed
[email protected]> select * from test where column2 like '%'||column1||'%';
10000 rows selected.
Elapsed: 00:00:00.18
Execution Plan
0 SELECT STATEMENT Optimizer=ALL_ROWS (Cost=23 Card=8328 Bytes=532992)
1 0 TABLE ACCESS (FULL) OF 'TEST' (TABLE) (Cost=23 Card=8328 Bytes=532992)
Statistics
5 recursive calls
0 db block gets
821 consistent gets
0 physical reads
0 redo size
702263 bytes sent via SQL*Net to client
7838 bytes received via SQL*Net from client
668 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
10000 rows processed
[email protected]> create index testidx on test(column2) indextype is ctxsys.context;
Index created.
[email protected]> select * from test where contains(column2, column1) > 0;
10000 rows selected.
Elapsed: 00:00:56.80
Execution Plan
0 SELECT STATEMENT Optimizer=ALL_ROWS (Cost=25008 Card=4 Bytes=284)
1 0 TABLE ACCESS (FULL) OF 'TEST' (TABLE) (Cost=25008 Card=4 Bytes=284)
Statistics
55201 recursive calls
0 db block gets
85857 consistent gets
0 physical reads
0 redo size
702263 bytes sent via SQL*Net to client
7838 bytes received via SQL*Net from client
668 SQL*Net roundtrips to/from client
204 sorts (memory)
0 sorts (disk)
10000 rows processedThanks in advance,
Anthony
Maybe you are looking for
-
Object type error while creating ECR
Hi All When creating a Engineering change request ECR (T.code: CC31), after entering the change type, selecting the object type(document & material) when i try to save the ECR, i am getting the following error message "is not a valid object type for
-
Changing a custom report to be time sensitive
Hi I posted this in FI too thought the MM people might have some inputs as to how to correct the Zvenclass if we use the standard SAP field on the accounting view table LFB1 MINDK minority indicator We need to change the custom report zvenclass, it i
-
Apps disabled on the Verizon Galaxy S6 and S6 Edge
Samsung Galaxy S6: Verizon, AT&T remove Microsoft apps | BGR I was curious about which features would be removed from the galaxy s6/ s6 edge on Verizon; Verizon has been known to remove features! (Which might have influenced a consumer's decision to
-
Defined table in function module
i wont to define a table with fields objid in import tab how can i do that? thankes
-
ERROR - JBO-25005: Object name for type View Object is invalid
Hi All, I am getting this error "JBO-25005: Object name for type View Object is invalid" while executing my VO query in Controller code. Can any one please tell me the reason behind this error? I am creating a VO dynamically and .xml file of a VO is