Reagrding some typical sql query in oracle8i
hi all,
i am facing a problem in sql query,My problem is like that
table emp data like that :
emp_id sal
10 1000
20 2000
30 3000
and i want to show data as follows-
emp_id sal
10 1000
20 3000
30 6000
just show the cumulative total of salary column.
plz its urgent.
ok
bye
SQL> create table t (emp_id number
2 ,sal number
3 );
Table created.
SQL> insert into t values (10, 1000);
1 row created.
SQL> insert into t values (20, 2000);
1 row created.
SQL> insert into t values (30, 3000);
1 row created.
SQL>
SQL>
SQL> select emp_id
2 , sal
3 , Sum (sal) over (order by emp_id) sum_sal
4 from t
5 /
EMP_ID SAL SUM_SAL
10 1000 1000
20 2000 3000
30 3000 6000
Similar Messages
-
Need some guidance - SQL Query Bind Variables for VO Object
Hi,
I'm trying to customize a custom page and I'm new to this. Can you please guide me or send me an example on how to do this?
1) VO is having the query as "SELECT INVOICE_NUM, INVOICE_DATE, INVOICE_AMOUNT, ...... from AP_INVOICES_ALL" (no parameters in the where clause)
2) Added VO to AM
3) XML PG is designed with MainRN, QueryRN, and Instance of VO1 as Table region. Selected INVOICE_NUM, INVOICE_DATE as Searchable. QueryRN is ResultbasesSearch.
4) Deployed to E-Biz and users were able to query using INVOICE_NUM or INVOICE_DATE fields that are available in the QueryRN.
Now, they want to add FROM_INVOICE_DATE and TO_INVOICE_DATE to the Search Condition. So, I have added the condition in the VO Query as "SELECT INVOICE_NUM, INVOICE_DATE, INVOICE_AMOUNT, ...... from AP_INVOICES_ALL WHERE INVOICE_DATE between :0 and :1".
How to add these fields FROM_INVOICE_DATE and TO_INVOICE_DATE to the QueryRN? These are not part of VO.
How to bind them to :0 and :1? I don't see any controller here? Do I need set a new controller and write logic for getting result set?
Any sample script or link would really help.
Thanks in advance.
RamHi Ram,
Hmmm, it is interesting.
Add two attributes to the page fromDate and toDate and in the controller class capture the values (like String fromDate = pageContext.getParameter("FromDate");) and invoke a method from AM and pass these parameters.
In the AM method call a method of VO and the VOImpl set and pass the bind parameters and execute the query again.
like
setWhereClause(" from_date = :1 AND to_date = :2");
setWhereClauseParams(null); // Always reset
setWhereClauseParam(0, fromDate);
setWhereClauseParam(1, toDate);
executeQuery();
Hope this will answer your question.
Krishna. -
Why some columns are not read into Power Pivot when reading data from a SQL query
I have this SQL query that I want to use to read data to PowerPivot from:
SELECT Score.FieldCount as fieldcount, Score.Record.GetAt(0) as predicted_gender, Score.Record.GetAt(1) as probability_of_gender, Score.Record.GetAt(2)
as probability_of_m,
Score.Record.GetAt(3) as probability_of_f, Score.Record.GetAt(4) as customerkey
FROM
SELECT * FROM dbo.myCLR1(
dbo.MyCLR2('c:\fILES\MLSM.xml'),
'SELECT * FROM [dbo].[Customer]') Input
) Score
After I click 'Finish' in "Table Import Wizard", I can only get 1 column (FieldCount) in Power Pivot window. Why don't I get the other 4 columns? If I save the result to a table I do get all columns but my goal is to dynamically present the result
so that's not an option. Can anyone shed some light?
Thanks,
Chu
-- Predict everything. http://www.predixionsoftware.comIf I only pass in query as
SELECT * FROM dbo.myCLR1(
dbo.MyCLR2('c:\fILES\MLSM.xml'),
'SELECT * FROM [dbo].[Customer]') Input
I do get 2 columns (FieldCount and Record as shown below)
-- Predict everything. http://www.predixionsoftware.com -
SQL query in some item.
I have a string item with this example value:
"SELECT 1 FROM dual"
Yes, this is SQL query.
Now I want to create PDF Report (Shared Components > Report Queries...) based on this SQL. I want to use this item (exactly, value from this item).
How can I do it? Is this possible?
regards,
JarekHello,
You can’t use “dynamic” SQL query within the Report Queries technique.
You can use, as Luis suggested, a report region based on function returning query, in order to construct your SQL query. You can read some more details in the following:
Re: ApEx PDF printing with Advanced support.
Re: Dynamic Column in SQL-Statement
Hope this helps,
Arie. -
Some hierarchy related issues, SQL Query is including unselected columns?
Hello Guys...
I have something strange happening in my report.. First of all, the RPD I have is built according to JDE model.
There is a schema which looks like this:
BU Dim ------->Fact<---------Account Dim <--------BU Account Dim (Indeed a copy of BU Dim)
A dim hierarchy is created as AccountDim with Account Desc at the lowest bottom level, the dimension key at that level is AcctID which is the unique identifier.
The issue comes when I created a report using Account, Account Desc, Fact Measures. The measures are not displayed as per account even if the joins and aggr levels are all defined correctly at the proper level..
I checked the sql that is generately, it is interested that whenever I include Account Desc column in the report, the SQL will include Actid column in the select and groupby part, which results in data being at the wrong level..
When I remove Actid from Account Hierarchy as the key, the report runs correctly and the SQL query won't include Actid column.. However, since the removal of the ACTid key from Account Hierarchy will cause other reports not running properly, I have to revert the change back to normal.. I'd like to know what to do in order to investigate more deeply as what's going on and as why the SQL will include columns fields that are not selected at answer levels..
Any suggestions will be greatly appreciately.. I'd like to provide the rpd file, but not sure how to..
Many ThanksHi, Vikeng,
Why use the salary table at all, if you're not ever getting any information from it?
Why not:
SELECT EmpName
, DeptName
, 'N/A' AS SalaryValue
FROM Employee
, Department
WHERE Employee.EmployeeId = Department.EmployeeId
Are you saying that somethimes there is a relationship, but not with this sample data?
If so, post some different sample data (CREATE TABLE and INSERT statements) that has a relationship for some rows, and not for others. Post the results you want from that data, and explain, with specific examples, how you get those results from that data.
You might just need an outer join. -
SQL Query works in SQL Developer, but not always in MII
Hi all,
I encountered a strange behaviour with a query in MII 12.0.2. Maybe someone has a guess what happens.
I have created a SQL query which runs against Oracle 10g tables. I have tested the query using SQL Developer, and it throws a couple of lines, depending on the contents of the where clause.
Next I have copied the query to a MII SQL Query (FixedQuery). However, the output is empty most of the time, without showing any errors. After some testing I got the impression that older data are not displayed, but there is no time or date setting in MII.
As the SQL Developer always returns rows, I am unsure where to search for the error.
Regards
MichaelMichael,
I would imagine that you have sub-select statements in your FixedQuery, all which will fall subject to the RowCount property of the query template (SQL defaults to 100), which is issued through the driver and typically honored by the database when returning the data from your request.
Most of the native database query tools allow you to make unbound query requests with no limit on rows, which would probably account for the difference between SQL Developer and the query template.
For SQLServer it's ROWCOUNT: http://msdn.microsoft.com/en-us/library/ms188774.aspx
For Oracle it's ROWNUM: http://www.oracle.com/technology/oramag/oracle/06-sep/o56asktom.html
So the answer would be not to make the query template row count some rediculous number, but more appropriately refine the way that the database request is issued.
Regards,
Jeremy -
Parse User Pasted Text and use in SQL query
I am trying to take some user pasted text (typically would come from Excel) and parse those values and put into a query.
text area:
":P11_text"
query:
"select *
from table
where column in :P11_text;"
I have tried some variations of replace and translate in order to parse that list of values...something like: translate(:P11_text, chr(10)||chr(13), ',' ).....and many variations of this.
I have been able to replace the end of lines with the commas, but it appears that I am not getting my single quotes captured, even when trying to force them in. The best attempt returned single quotes and commas in between values but not at the beginning and end of the list of values.
I would bet that there is an easy way to accomplish this or an easy way to accomplish the requirement in a different way altogether.
Please point me in the right direction.I finally got this one figured out!
create or replace type myTableType as table
of varchar2(4000)
create or replace
function in_list( p_string in varchar2 ) return myTableType
as
l_string long default p_string || ',';
l_data myTableType := myTableType();
n number;
begin
loop
exit when l_string is null;
n := instr( l_string, ',' );
l_data.extend;
l_data(l_data.count) :=
ltrim( rtrim( substr( l_string, 1, n-1 ) ) );
l_string := substr( l_string, n+1 );
end loop;
return l_data;
end;
--The SQL Query is:
select *
from t wher c in (select *
from THE
( select cast( in_list(translate(:p10_prolist,chr(10)||chr(13),',')) as
mytableType ) from dual ) a);
--Working like a champion!!! -
HELP! SQL Query: Other ways to reorder column display?
I have a SQL query report with a large number of columns (users can hide/show columns as desired). It would be great if the column display order could be changed by changing the order of the columns in the SELECT list in the Report Definition, but that doesn't work -- it puts changed or added columns at the end regardless of the order in the SELECT list of the query.
Is there some other way to reorder the columns displayed without using the Report Attributes page? It's extremely tedious to move columns around using the up/down arrows which redisplays the page each time. Am I missing a way to change display order, or does anyone have a "trick" to do this? It's so painful....
When defining forms you can reoder columns by specifying a sequence number for each column. Just curious as to why reports were not done the same way, and are there any plans to address this in a future release?
KarenYes, reordering columns is extremely painful.
It is supposed to be much improved in the next version.
See
Re: Re-ordering columns on reports
Moving columns up/down in Report Attributes
See my example at
http://htmldb.oracle.com/pls/otn/f?p=24317:141
Basically, let the users move columns around until they are blue in the face, provide a Save button to save the column order in a user preference and reorder the columns when the page reloads.
Or you can use Carl's PL/SQL shuttle as the widget to specify the columns shown and their order. The shuttle is at http://htmldb.oracle.com/pls/otn/f?p=11933:27
Hope this helps.
Message was edited by:
Vikas -
Can we use formula column in lexical parameter in sql query ...
hi
can we use formula column in lexical parameter in sql query ...
as example
i want to give
select * from & c_table
forumula
function c_table
if :p_sort = 1 then
return 'dept'
else
return 'emp'
end;
c_table formula column
is this possible ...
i have such example in oracle apps reports
if i try in ordinary report usinf emp table it show error ..
how we can give formula column...
please help me in this regard...
Edited by: 797525 on Feb 20, 2012 9:31 PMthanks sir,
iam not exactly saying select * from &c_table but some thing that like columns in select stmt also will be populated in user_parameters ,there are lot of table select.......from mtl_demand md, mtl_system_items msi, mtl_txn_source_types mtst, mtl_item_locations loc &C_source_from &C_from_cat
&c_source_from and &c_from_cat formula column and there are defined at report level only ......
pl/sql code &c_source_from is
function C_source_fromFormula return VARCHAR2 is
begin
if :P_source_type_id = 2 then return(',MTL_SALES_ORDERS mkts');
else if :P_source_type_id = 3 then return(',GL_CODE_COMBINATIONS gl');
else if :P_source_type_id = 6 then return(',MTL_GENERIC_DISPOSITIONS mdsp');
else if :P_source_type_id = 5 then
if :C_source_where is null then
return NULL;
else
return(',WIP_ENTITIES wip');
end if;
else if :P_source_type_id = 8 then return(',MTL_SALES_ORDERS mkts');
else if :P_source_type_id is null then
return(',MTL_SALES_ORDERS mkts,
MTL_GENERIC_DISPOSITIONS mdsp,
GL_CODE_COMBINATIONS gl ');
else null;
end if; end if; end if; end if; end if; end if;
RETURN NULL; end;
this is forumula column i hope that you understand what iam saying
please help me in this regard....
thanking you... -
'is null' not working in dynamic sql and SQl Query component (OBPM 10gr3)
I'm using a SQL Query component with sql like this
'select col1, col2 from table where col3 is null'
for some reason this does not work.
Has anybody faced this issue? Is there a known bug with handling nulls
Thanksplz post which DB version u r working with
dont use paramters in Procedure with : sign
Write simply the name of the Paramters like p_userid etc etc
this might help u as well
http://baigsorcl.blogspot.com/2010/02/get-rid-of-addtional-quotes-with-quote.html -
Report- Pl/sql function returning sql query parsing page items as text?
Hi Team,
I am facing a strange issue .
I have four page items namely
1)JOB_CODE
2)MIN_EXP
3) MAX_EXP
4) SOURCES1
I have a report of the type "Pl/sql function returning sql query"
declare
v_sql varchar2(4000);
begin
if (:JOB_CODE IS NOT NULL and :MIN_EXP IS NOT NULL and :MAX_EXP IS NOT NULL and :SOURCES1 IS NOT NULL) then
v_sql:= 'select v_candidate_id, v_fname,v_current_employer,v_Experience_years from candidature where V_REQUIREMENT = :JOB_CODE and v_experience_years >= :MIN_EXP and v_experience_years <= :MAX_EXP and source like ' || '''' || '%'|| ':SOURCES1' || '%' || '''';
elsif (:JOB_CODE IS NULL and :MIN_EXP IS NOT NULL and :MAX_EXP IS NOT NULL and :SOURCES1 IS NOT NULL) then
v_sql := 'select v_candidate_id, v_fname,v_current_employer,v_Experience_years from candidature where v_experience_years >= :MIN_EXP and v_experience_years <= :MAX_EXP and source like ' || '''' || '%'|| ':SOURCES1' || '%' || '''';
elsif (:MIN_EXP IS NULL and :JOB_CODE IS NOT NULL and :MAX_EXP IS NOT NULL and :SOURCES1 IS NOT NULL) then
v_sql := 'select v_candidate_id, v_fname,v_current_employer,v_Experience_years from candidature where v_experience_years <= :MAX_EXP and V_REQUIREMENT = :JOB_CODE and source like ' || '''' || '%'|| ':SOURCES1' || '%' || '''';
elsif (:MAX_EXP is null and :JOB_CODE IS NOT NULL and :MIN_EXP IS NOT NULL and :SOURCES1 IS NOT NULL) then
v_sql := 'select v_candidate_id, v_fname,v_current_employer,v_Experience_years from candidature where V_REQUIREMENT = :JOB_CODE and v_experience_years >= :MIN_EXP and source like ' || '''' || '%'|| ':SOURCES1' || '%' || '''';
end if;
insert into query_list values (v_sql);
insert into debug values (:JOB_CODE , :MIN_EXP , :MAX_EXP , :SOURCES1);
return v_sql;
end;
Please not that I am insertin the query into a table called Query_list and the page item values into the table called Debug thru the pl/sql function which returns teh query.
Now I select the data from the debug tables.
select unique(query) from query_list;
select v_candidate_id, v_fname,v_current_employer,v_Experience_years from candidature where V_REQUIREMENT = :JOB_CODE and v_experience_years >= :MIN_EXP and v_experience_years <= :MAX_EXP and source like '%:SOURCES1%'
select * from debug;
JOBCODE MINEX MAXEX SOURCE
21 1 10 donkeyHire
And if I run the query in sql I get some records returned
select v_candidate_id, v_fname,v_current_employer,v_Experience_years from candidature where V_REQUIREMENT = 21 and v_experience_years >= 1 and v_experience_years <= and source like 'donkeyHire'
V_CANDIDATE_ID V_FNAME V_CURRENT_EMPLOYER V_EXPERIENCE_YEARS
2 Vengu Andale Tech 4
But the record does not show up in the report!
does this type of report parse page items as text?
Why is it so?
Waiting for an early reply.
Thanks,
venkatVenkat - You don't want to put ':SOURCES1' in quotes like that.
Scott -
How can I show all the results returned by a sql query?
Hi guys,
I need your help.
Let's say I have one table: TableA. Fields of TableA are aleg, anon, apes. The following sentence can return, in general, several rows: select anon from TableA where aleg = somevalue. I'd like to show the result of column anon but no luck. If I try to show the results in a TextArea and the origin is an sql query only shows the first row value. I tried Show as: show as text (based in PLSQL) and coding an anonymous plsql block as
DECLARE
v_anon TableA.anon%TYPE;
CURSOR v_cur IS
select anon from TableA where aleg = somevalue;
BEGIN
OPEN v_cur;
LOOP
FETCH v_cur INTO v_anon;
EXIT WHEN v_cur%NOTFOUND;
:FIELD_IN_FORM := v_anon;
END LOOP;
CLOSE v_cur;
END;
but in this case it's not shown any result.
So the first question is what kind of field should I use to show the result. And the second one is what can I do to being able to show all the results returned by the query (provided that is more than one single row).
regardsHi Denes,
Just starting with apex. I think I know how to show the results in a report region. I've simplified the posted question.
A more detailed question would be: Suppose you have a region where you have put several text areas to accommodate the result of a multi-column query (lets say for TableA) that only returns one row, each column value returned put in a different text area. Also you want to show the values of other fields in TableB that depends on some value just retrieved from TableA and that you want all values retrieved (from TableA and the linked TableB) to be show in the same region. Is that possible? If yes, how?
Thank you in advance -
How to run a sql query from a button in apex 3.0
Hi,
I am brand new and went through/installed the obe project tracker. I have need to create a simple application that displays a result (2 fields, name and license number) based on two parameters (dob and login id) which all are stored in 1 table in the database. I could this very simply in VB or VB.net but have no idea how to do it in apex.
Please provide guidance,
Thank you,
TomHi Tom,
Sounds like a report region will satisfy your requirements.
Create a new report region on one of your pages.
Choose SQL Report and give the region a title.
When you get to the "Enter SQL Query or PL/SQL function returning a SQL Query:" step, type:
SELECT name, license_number
FROM <insert_your_table_name_here>
WHERE dob = :P<n>_dob
AND login_id = :P<n>loginid(replace <n> with the page number that the region is on and use your own table name).
Don't try to run the page yet - it will give 'No data found'
Now, go back to the Page Definition screen and add two items in the region you just created - call them P<n>dob and P<n>login_id
Then, create a button in the same region (to be displayed amongst the region's items) - call it P<n>_GO and click 'Create' (take all the other defaults).
Now you can run the page, put some values into the fields and click go.
If you want to get fancier, you can change the text items to select lists etc. - let us know if you need help with that.
Hope this helps,
Bryan. -
How to execute a SQL Query in Ms-Access
Hi,
I've a query which fetches the data from the tables based on daily transactions.
I mean, the data gets updated daily basis.
Now, i want to send the user a Ms-access work sheet with the query written, so that when ever the query is executed, it would fetch the records (with latest updates).
I found some documents in google to, how to write sql query in ms-access.
How ever, i'm unable to find the connection setup.
how do i connect to oracle database using ms-access??
Can any one please help me regarding this.
Thanks,
SanthoshYou can try this tutorials
http://www.reo.gov/gis/tools/infobase/LinkAccessToOracle.pdf
Basically steps include,
Install and configure Oracle client
Configure ODBC DSN using correct TNS name configured in first step
Link the table from Msaccess, make sure you linked the table not import it. -
How to write a SQL query in SAP B1 2007 B with input parameters?
How to write a SQL query in SAP B1 2007 B with input parameters, on execution of which will ask for some input value from the user and the values will be selected from a list such as item list?
The syntax like
SELECT * FROM OITM T0 WHERE T0.ItemCode = '[%0\]'
Thanks,
Gordon
Maybe you are looking for
-
F11 is not working properly in my hp pavillion g6
my f11 key is not working well ....so my audio is not working well...cozz audio is attach with f11 key...suggest me now what to do pLz
-
How to deploy a Webapplication on WAS more than one times on same server?
Hi all, I 've a special problem: In our web-app (some DC's) also stored propertie-Files. Now we would to deploy this application more than one times at same server using different WebContentRoots. (f.e. http://server/app1 and http://server/app2 a.s.o
-
Custom Border painting over scrollpane and toolbar
I found a LineNumberBorder class in these here forums (I'll post this same question there too) and adapted it to add line numbers to a JTextPane derived class. When the border is added to the textpane it paints line numbers to the left of each line i
-
Scroll bar only scrolls the top ~300 pixels
The latest update of Nightly is unusable. The scroll bar only changes the top 300 pixels or so of the page. Then the links do not work in the bottom portion, and you can't see the entire page. Troubleshooting info: "application": { "name": "Firefox",
-
LR4 beta white balance on cropped images
I'm not sure if this has been discussed, I could not find a post with silimar issues. LR4 Beta 64 on WinVista : Nex 5N raw files WB picker on a cropped image seems to give variable (and wrong) results I wanted to tweak WB an image that I'd previously