Returned records different in query to workbook
We are using Bex Analyser version 7.
I have a pending invoices query embedded in a workbook. If I refresh the query within the workbook, I get 3 fewer records than if I run the same query on its own.
When I identified the 3 invoices concerned I could see that they have a zero key figure values. I haven't suppressed zero records in the query but they appear to be suppressed in the workbook.
Has anybody got any suggestions for amending my workbook so that I get all the records?
Many thanks,
Positive Parrot
Hi,
Can you check in this way.
Right click on a particular record in workbook-> properties> calculation---> calculate single value as.
Thanks,
Ashok
Similar Messages
-
Web client returned different no. of records in same query
May anyone can help me ?
I am now using Web Client 9.2.0.0.196 Windows XP.
I am only an user to retrieve records using one static query thorugh Hyperiion Interactive Reporting Web Client for business purposes. The back-end database would be updated monthly.
We set the request and filter within one Dimension of the query. However, I tried the query 10 times, the number of records returned was different.
I trired to set filter with different values. Sometimes, it gave me correct number of records and sometime it could not.
My IT team reported that the Expert of Hyperion Verdor also cannot resolve my problem.As you are using the Web Client there are many parts involved in the process of your running a query.
Below is an example of a very basic path a query takes to DB
1. PC- Web Browser with Web Client
2. Web Server
3. Application Server
a. Hyperion BI Server
b, Hyperion DAS - Data Access
4. Database.
Anywhere between 1 and 4 there may be firewalls, network switches etc.
If you are getting unexpected results on you query then I would start with taking the Query/SQL being sent via the Web Client and trying it on a SQL Client Tool for that Database from your PC and see what you get.
Other Troubleshooting actions:
- Have DBA monitor the Database and see if they can capture your SQL being sent and see if they can see if there are problems on DB.
- Have Hyperion Administrator look at the Logs for the BI Server, DAS and Usage Tracking to see if there are any anomolies.
- I would see if you are experiencing the same problem from a different workstation.
- Check for Network Time Outs....How long is it taking for your Query to Run? Maybe you are dropping connection somewhere in the process.
Hope this is helpful.
Wayne -
Query returns record in SQL Developer but not in iSQLPlus
... back in a minute, I may not have done a commit at the end of the insert.
The problem I was having was I hadnt commited the record in SQL Developer but the queries where returning records in this environment but not in iSQLPlus or Apex and it was confusing me.
Message was edited by:
Benton
Message was edited by:
BentonFinally got to know the reason why Timezone Abbr woudn't show up in SQL Plus.
I ran below query in SQL PLUS
SELECT SESSIONTIMEZONE, CURRENT_TIMESTAMP, systimestamp, LOCALTIMESTAMP FROM DUAL;
SESSIONTIMEZONE CURRENT_TIMESTAMP SYSTIMESTAMP LOCALTIMESTAMP
-05:00 08-SEP-12 12.00.31.575228 AM -05:00 08-SEP-12 12.00.31.575223 AM -05:00 08-SEP-12 12.00.31.575228 AM
Now executed the same query in SQL Developer:
SESSIONTIMEZONE CURRENT_TIMESTAMP SYSTIMESTAMP LOCALTIMESTAMP
America/Chicago 08-SEP-12 12.08.32.072424000 AM AMERICA/CHICAGO 08-SEP-12 12.08.32.072420000 AM -05:00 08-SEP-12 12.08.32.072424000 AM
The difference between the 2 outputs is the way in which time_zones were respresented. In SQL PLUS, it is shown as an offset whereas in SQL Developer as a time zone region name. Now there are many "time sone regions" that follow an offset of -5:00. This confuses Oracle and a "UNK"(Unknown) for a query like the one below when trying to execute in SQL PLUS:
select extract(timezone_abbr from from_tz(cast(sysdate as timestamp),SESSIONTIMEZONE)) from dual;
EXTRACT(TI
UNK
Therefore we need to specify the exact Time Zone Region(TZR) in order to obtain the corresponding TZD(Daylight Savings Format i.e. CDT or CST). This we do by altering the session environment vaiable time_zone
alter session set time_zone='America/Chicago';
Now executing the queries to find the abbreviated time zone( in TZD format) will finally work to return a non-null char value.
select extract(timezone_abbr from from_tz(cast(sysdate as timestamp),SESSIONTIMEZONE)) from dual;
EXTRACT(TI
CDT
select to_char(CURRENT_TIMESTAMP, 'TZD') from dual;
TO_CHA
CDT -
Variable to hold the number of records returned by the SQL Query.
Hi folks,
Is there any way to hold the number of records that could be returned by the SQL query we use to make a report?
If so, please do come up with the answer.
Cheers,
PCZ.Hi there,
Well, there is no actual business requirement.
It is just the curiosity of mine.
I would like to handle
1) the number of records our report query returns or
2) the query itself
to write a better pl/sql code in any trigger/program unit, if any business logic beckons in future.
Cheers,
PCZ. -
Populate Result of query in Different worksheets of One Workbook in Excel.
I want to get output of different queries to be populated in Different Sheets of a workbook of Excel in Unix/Linux Environment.
Here is an example perl script using the Spreadsheet::WriteExcel CPAN module that might help:
===#!/usr/bin/perl
use strict;
use DBI;
use Spreadsheet::WriteExcel;
my ($toc,$data_sheet,$f,%data,$workbook) = ();
my ($workbook_filename) = "mytest.xls";
$workbook = Spreadsheet::WriteExcel->new($workbook_filename);
sub build_excel_workbook {
$workbook->compatibility_mode();
$f = \%{$data{excel_format}};
$$f{bold} = $workbook->add_format();
$$f{bold}->set_bold();
$$f{right_align} = $workbook->add_format();
$$f{right_align}->set_align("right");
$toc = \%{$data{excel_table_of_contents}};
$$toc{tab} = $workbook->add_worksheet("Table of Contents");
$$toc{tab}->freeze_panes(1,0);
$$toc{tab}->set_column(0,1,20);
$$toc{tab}->write(0,0,"WorkSheet Name",$$f{bold});
$$toc{tab}->write(0,1,"Comments",$$f{bold});
$data_sheet = \%{$data{excel_data_sheet}};
$$data_sheet{tab} = $workbook->add_worksheet("EMP table");
$$data_sheet{current_row} = 0;
$$toc{tab}->write(1,0,"EMP table");
$$toc{tab}->write(1,1,"Example WorkSheet containing EMP sample data");
build_excel_workbook();
my $db = DBI->connect( "dbi:Oracle:Local", "scott", "tiger" )
|| die( $DBI::errstr . "\n" );
$db->{AutoCommit} = 0;
$db->{RaiseError} = 1;
$db->{ora_check_sql} = 0;
$db->{RowCacheSize} = 16;
my $SEL = "SELECT * FROM EMP";
my $sth = $db->prepare($SEL);
$sth->execute();
while ( my @row = $sth->fetchrow_array() ) {
for (my $i = 0; $i <= $#row; $i++) {
$$data_sheet{tab}->write($$data_sheet{current_row},$i,$row[$i]);
$$data_sheet{current_row}++;
END { $db->disconnect if defined($db); }
#end_script===
Best Regards,
Bryan Wood
Edited by: BryanWood on Jan 26, 2012 4:07 PM
Edited by: BryanWood on Jan 26, 2012 4:10 PM -
Reports not returning records utilizing different currency type.
Good morning,
My company has numerous subsidiaries utlizing CRM On Demand. Although our defauct currency is USD, one of our operations enters opportuntiy data in Canadian dollars. Both currency types are active in the system but for some reason, the custom reports I have created are not returning records created by our Canadian company entering in CAD.
There is probably a quick solution, but so far I have yet to find it! Thanks in advance for your feedback!
Ryanyes...your report won't show data for canadian currency. even the admins won't be able to see it.
try this fix instead:
you will have to create a new field for currency in the opty page layout and change it to canadian dollar otherwise the currency would still appear as USD in the database.
Then use this field in your reports.
This should help. please let us know your feedback. -
Return records from Stored Procedure to Callable Statement
Hi All,
I am createing a web application to display a students score card.
I have written a stored procedure in oracle that accepts the student roll number as input and returns a set of records as output containing the students scoring back to the JSP page where it has to be put into a table format.
how do i register the output type of "records" from the stored function in oracle in the "registerOutParameter" method of the "callable" statement in the JSP page.
if not by this way is there any method using which a "stored function/procedure" returning "record(s)" to the jsp page called using "callable" statement be retrieved to be used in the page. let me know any method other that writing a query for the database in the JSP page itself.I have a question for you:
If the stored procedure is doing nothing more than generating a set of results why are you even using one?
You could create a view or write a simple query like you mentioned.
If you're intent on going the stored procedure route, then I have a suggestion. Part of the JDBC 2.0 spec allows you to basically return an object from a CallableStatement. Its a little involved but can be done. An article that I ran across a while back really helped me to figure out how to do this. There URL to it is as follows:
http://www.fawcette.com/archives/premier/mgznarch/javapro/2000/03mar00/bs0003/bs0003.asp
Pay close attention to the last section of the article: Persistence of Structured Types.
Here's some important snippets of code:
String UDT_NAME = "SCHEMA_NAME.PRODUCT_TYPE_OBJ";
cstmt.setLong(1, value1);
cstmt.setLong(2, value2);
cstmt.setLong(3, value3);
// By updating the type map in the connection object
// the Driver will be able to convert the array being returned
// into an array of LikeProductsInfo[] objects.
java.util.Map map = cstmt.getConnection().getTypeMap();
map.put(UDT_NAME, ProductTypeObject.class);
super.cstmt.registerOutParameter(4, java.sql.Types.STRUCT, UDT_NAME);
* This is the class that is being mapped to the oracle object.
* There are two methods in the SQLData interface.
public class ProductTypeObject implements java.sql.SQLData, java.io.Serializable
* Implementation of method declared in the SQLData interface. This method
* is called by the JDBC driver when mapping the UDT, SCHEMA_NAME.Product_Type_Obj,
* to this class.
* The object being returned contains a slew of objects defined as tables,
* these are retrieved as java.sql.Array objects.
public void readSQL(SQLInput stream, String typeName) throws SQLException
String[] value1 = (String[])stream.readArray().getArray();
String[] value2 = (String[])stream.readArray().getArray();
public void writeSQL(SQLOutput stream) throws SQLException
}You'll also need to create Oracles Object. The specification for mine follows:
TYPE Detail_Type IS TABLE OF VARCHAR2(1024);
TYPE Product_Type_Obj AS OBJECT (
value1 Detail_Type,
value2 Detail_Type,
value3 Detail_Type,
value4 Detail_Type,
value5 Detail_Type,
value6 Detail_Type,
value7 Detail_Type,
value8 Detail_Type);Hope this helps,
Zac -
Hi
Can anyone of you please give me some information or any links explaning step by step procedure on:
1. How to copy a query
2. How to insert query in Workbook
Many ThanksHello,
1. How to copy a query
Open the Query Designer and choose edit of the query then choose "Save as". This will copy your query. You can also use transaction RSZC to copy queries between different InfoProviders if possible
2. How to insert query in Workbook
Just open the workbook, go to the place you want and click on the option Tools->Insert query (with BW 3.x); With BI 7, just open your workbook, choose a place you want to insert the query and click on the table button, then you have to assign that table to a dataprovider (a query)
Diogo. -
Is it possible to build Query on workbook?
ie: Is it possible to summarize the results of two querys and to display the result in another query.
Problem: Due to wrong definition of field the data get overflowed and results in sql error in query.
Now if i change the field definition thant its a risky process due to the data presence for field in different target.
Instead of that i have planned to built two queries with different selection and summarize the result in third query and attach the third query in webtemplate for web reporting.
Sure points for valid inputs.
Thanks in advance.Hi Armstrong,
Yes, it is possible to summarize the results of two querys and to display the result in another query by using workbook.
Create a workbook with the two queries in two seperate worksheets(sheet1 & sheet2) in the workbook.
Take a new work sheet(sheet3) for the 3rd query i.e. result query. In this worksheet you copy the result of 1st query and 2nd query and add it
or
You can write a formulia for adding these two query result.
Select the cell which you want the summiation of 1st and 2nd query to be displayed in sheet3. Type = in that cell and click the sheet1 and select the result of 1st query ( we displayed 1st query in sheet1) then type + and click sheet2 and select the result of 2nd query ( we displayed 2nd query in sheet2) then press enter. Now you can see the summiation of these two queries in that cell in sheet3.
Now attach this workbook in webtemplate for web reporting.
I hope you understand the procedure. If you have any clarifications let me know.
Regards,
Patil. -
Query and Workbook BI 7.0
Hi
I am in BI 7.0
1)I created a query X and saved it as workbook. When I edit the changes in query, I don't see the changes reflected in workbook.I thought if I change the query or workbook, the changes should take place.
2) I have to create 12 queries of same structure but contains different hardcoded costcenters.Can somebody advice me what is the best method to accomplish the above requirement.Should I create query or query views and what major differences did you guys observe between Query and Query View from your expereince and practices...Hi Jacky,
If you change the query this way you wont have to re-insert the query each time you make changes.
1. Open the workbook.
2. Select the query by clicking on it. Then use the Edit query option from the toolbar.
3. Make changes to the query.
4. Execute the query by clicking the Green check mark.
5. After making sure that the changes have been applied, save the workbook.
Hope this helps... -
Join 3 tables, return records which no match found in table 1 as null
Hi Gurus,
I really need your expert advice. I am stuck in below query.
I have joined 3 tables,
table 2 is an information reference (to get the process code and process name)
table 1 have and table 3 have daily data (which will have the process code and its values/qty)
all values return from table 1 and 3(rtrwip00 and prdyld01) should refer to code in table 1.
There can be a scenario where on a day, a process was stop, so it dont have values/qty in table 1/3,
The problem is my query will return only rows which have records in table 1/3.
While I want all the records in table 2 to be returned no matter have data or not in table 1/3, in case no data in table 1/3, return qty as '0'.
Please advice me..thanks in advance :)
Select lot.rw_oper,
lot.rw_area_grp,
lot.rw_oper_name,
proc_out.proc_out,
lot.rw_qty
from
( SELECT UNIQUE a.rw_oper,a.rw_area_grp,a.rw_oper_name,SUM(CASE WHEN a.rw_qty_unit = 'CM' THEN a.rw_qty*10 ELSE rw_qty END )as rw_qty
From rtrwip00 a, oprinf99 b
WHERE a.rw_facility='MIPOPRD'
AND b.oi_facility = a.rw_facility AND b.oi_oper = a.rw_oper
GROUP BY a.rw_area_grp,a.rw_oper,a.rw_oper_name
ORDER BY a.rw_oper,a.rw_area_grp) lot,
( SELECT py_oper, SUM(CASE WHEN py_out_unit1 = 'CM' THEN py_proc_out1*10 ELSE py_proc_out1 END) proc_out
FROM prdyld01
WHERE py_facility = 'MIPOPRD'
AND py_trs_time between TO_CHAR(SYSDATE-1,'YYYYMMDD')||'070000' AND TO_CHAR(SYSDATE,'YYYYMMDD')||'070000'
group by py_oper
)proc_out
where lot.rw_oper NOT IN ('2900','6700' ,'9100' ,'9920' ,'9921','9940','9941','9300','9500','6700','8910', 'REJT')
and lot.rw_oper = proc_out.py_oper
order by lot.rw_operCREATE TABLE PRDYLD01
PY_FACILITY VARCHAR2(12 BYTE) NOT NULL,
PY_TRS_TIME VARCHAR2(14 BYTE) NOT NULL,
PY_LOT VARCHAR2(11 BYTE) NOT NULL,
PY_OPER VARCHAR2(4 BYTE) NOT NULL,
PY_PO VARCHAR2(12 BYTE) NOT NULL,
PY_PROC_IN1 NUMBER(10,2) DEFAULT 0 NOT NULL,
PY_PROC_IN2 NUMBER(10,2) DEFAULT 0 NOT NULL,
PY_PROC_OUT1 NUMBER(10,2) DEFAULT 0 NOT NULL,
PY_PROC_OUT2 NUMBER(10,2) DEFAULT 0 NOT NULL,
sample data 1
PY_OPER PROC_OUT
3000 481
3100 214
3200 642
3250 291
5250 519
5300 439
5350 476
CREATE TABLE RTRWIP00
RW_FACILITY VARCHAR2(12 BYTE) NOT NULL,
RW_LOT VARCHAR2(11 BYTE) NOT NULL,
RW_OPER VARCHAR2(4 BYTE) NOT NULL,
RW_OPER_NAME VARCHAR2(35 BYTE) NOT NULL,
RW_PO VARCHAR2(12 BYTE) NOT NULL,
RW_AREA_GRP VARCHAR2(12 BYTE) NOT NULL,
RW_QTY NUMBER(10,2) DEFAULT 0 NOT NULL,
RW_QTY_UNIT VARCHAR2(6 BYTE) NOT NULL,
sample data 2
RW_OPER RW_QTY
3000 1248
3100 324
3200 133
3250 357
4400 424
4500 821
4600 909
5050 689
5250 2472
5300 53
5350 166
CREATE TABLE OPRINF99
OI_FACILITY VARCHAR2(12 BYTE) NOT NULL,
OI_OPER VARCHAR2(4 BYTE) NOT NULL,
OI_OPER_SEQ NUMBER(5) NOT NULL,
OI_AREA_GRP VARCHAR2(12 BYTE),
OI_SHORT_DESC VARCHAR2(10 BYTE) NOT NULL,
OI_LONG_DESC VARCHAR2(35 BYTE),
sample data 3
RW_OPER RW_AREA_GRP RW_OPER_NAME
3000 MOD ROD MOUNT
3100 MOD WIRE SAW
3200 MOD AS-CUT CLEANER
3250 MOD BEAM REMOVAL
4400 POL ESE-II
4500 POL EDGE OXIDE STRIP
4600 POL LTO INSPECTION
5050 POL DOUBLE SIDE BUFFER
5250 POL ACCUMULATION
5300 POL FINAL POLISHER
5350 CLN POST POLISH CLEANER
ABove is the DLL for the table and its mock data.
Sample output should be like below; where when no data found in sample data 1, it will return '0'
RW_OPER RW_AREA_GRP RW_OPER_NAME PROC_OUT RW_QTY
3000 MOD ROD MOUNT 481 1248
3100 MOD WIRE SAW 214 324
3200 MOD AS-CUT CLEANER 642 133
3250 MOD BEAM REMOVAL 291 357
4400 POL ESE-II 0 424
4500 POL EDGE OXIDE STRIP 0 821
4600 POL LTO INSPECTION 0 909
5050 POL DOUBLE SIDE BUFFER 0 689
5250 POL ACCUMULATION 519 2472
5300 POL FINAL POLISHER 439 53
5350 CLN POST POLISH CLEANER 476 166
mY current output is below; only return record that have match to all table.
RW_OPER RW_AREA_GRP RW_OPER_NAME PROC_OUT RW_QTY
3000 MOD ROD MOUNT 481 1248
3100 MOD WIRE SAW 214 324
3200 MOD AS-CUT CLEANER 642 133
3250 MOD BEAM REMOVAL 291 357
5250 POL ACCUMULATION 519 2472
5300 POL FINAL POLISHER 439 53
5350 CLN POST POLISH CLEANER 476 166
Really appreciate your response, sorry for taking time to reply.
Thanks in advance :) -
[HELP] Procedure return records
Hi All,
I want to create a procedure that will return records (not only single record) base on some parameters. Is it possible?
While i used MS SQL Server, it is just a simple way. In the body of procedure i just need to call select query with some parameters in where clause. For example:
Create procedure GetEmployee
@grade char(1)
As
Select * From Employee Where EMP_Grade=@grade
Please help me!First off, what are you going to do with the records that are returned here?
Second, you can return a REF CURSOR
CREATE OR REPLACE PACKAGE refcursor_demo
AS
TYPE emp_refcursor_strong IS REF CURSOR RETURN emp%rowtype;
TYPE emp_refcursor_weak IS REF CURSOR;
-- You can define either procedures that have the strongly typed
-- REF CURSOR as an OUT parameter or you can define a function that
-- returns the REF CURSOR.
PROCEDURE refCursorProc( employees OUT emp_refcursor_strong );
FUNCTION refCursorFunc RETURN emp_refcursor_weak;
END;
CREATE OR REPLACE PACKAGE BODY refcursor_demo
AS
PROCEDURE refCursorProc( employees OUT emp_refcursor_strong )
AS
BEGIN
OPEN employees FOR
SELECT * FROM emp;
END;
FUNCTION refCursorFunc RETURN emp_refcursor_weak
IS
out_cursor emp_refcursor_weak;
BEGIN
OPEN out_cursor FOR
SELECT * FROM emp;
RETURN out_cursor;
END;
END;Alternately, you could return a collection, potentially in a pipelined table function.
Justin -
Mail merge doesn't see all records in Access query
Office 13 running on Win 8.1.
I have a query in Access that show 4 records when I run it. If I specify this query as my data source (select recipients) and then choose to edit the recipient list, there are only two records! The query in Access looks like this:
SELECT Membership.[m-nbr], Membership.[m-first], Membership.[m-member-since], Membership.[m-pick], Contact.[c-zip], Regions.[r-region-name], Regions.[r-region-director], Regions.[r-region-email], Membership.[m-member-since], Associates.[a-first-name], Associates.[a-id]
FROM ((Membership INNER JOIN Contact ON Membership.[m-nbr] = Contact.[c-nbr]) INNER JOIN (Regions INNER JOIN [Region/State] ON Regions.[r-region] = [Region/State].[rs-region]) ON Contact.[c-state] = [Region/State].[rs-state]) LEFT JOIN Associates ON Membership.[m-nbr]
= Associates.[a-nbr]
WHERE (((Membership.[m-pick])=True) AND ((Associates.[a-id]) Like "*A" Or (Associates.[a-id]) Is Null) AND ((Year([m-member-since]))=Year(Date())))
ORDER BY Contact.[c-zip];
If I remove this part: "((Associates.[a-id) Like "*A" Or (Associates.[a-id] is Null AND" then all 4 records show up in the recipient list.
In short, members can have multiple associates, but only the"A" associate is to be included in this letter. (associates have the same number as the member, with an a,b,c etc. appended. A member number could be 8741 and an associate number 8741A.
Why is this happening? Thanks, ~Steve
Steve WoodwardHmm, I tend to work in SQL mode when creating queries in Access - in that case, it doesn't change what you write. But I see that in the tabular Design mode it does change to ALIKE and that it works OK - something I wasn't aware of. I read that ALIKE is supposed
to allow "%" and "_" even when the database is in "Jet mode.
FWIW in ANSI mode, I would not expect LIKE "%a" to work in Access but it should work from OLE DB
But in any case, it still works OK here, so still not sure what is wrong.
As a workaround, it might be necessary either to export the query results from Access, then use the exported data as your source, use the query to create a new table and use that as the data source, or connect using DDE (to do that, in Word, you have to
check Options->Advanced->General->Confirm file format conversion on open. Then go through the connection process again and select the .accdb/.mdb. If it's a .accdb, you will have also have to check "Show all" when you get to the "Confirm Data Source"
dialog box. At that point, you need to select the "MS Access Databases via DDE" option from the list (even if you have a .accdb, which isn't listed in the file types for that connection method).
All of these approaches have their disadvantages (e.g. DDE may not connect easily and probably won't return Unicode data correctly) but may at least give you another avenue of investigation.
Peter Jamieson -
Sort orrder differance in query output on giving IN filter
I have two simple tables Country and Status
Their data are
Country table
C_ID C_NAME
1 INDIA
2 USA
3 UK
4 JAPAN
5 KOREA
6 AUSTRALIA
Status table
STAT_ID STAT_CD
1 AAA
2 BBB
3 CCC
4 DDD
5 EEE
6 FFF
I have a third table Customer, with foreign keys to Country and Status
Customer table
Customer_ID
Customer_Name
Customer_code
Country_id
Customer_Stat
100 Cust_100 AA 4 4
101 Cust_101 AA 5 5
119 Cust_119 AA 5 5
118 Cust_118 AA 4 4
117 Cust_117 AA 3 3
116 Cust_116 AA 2 2
115 Cust_115 AA 1 1
114 Cust_114 AA 6 6
113 Cust_113 AA 5 5
112 Cust_112 AA 4 4
111 Cust_111 AA 3 3
110 Cust_110 AA 2 2
First I query the Customer table with query
SELECT * FROM (SELECT row_.*, rownum rownum_
FROM (SELECT a.CUSTOMER_ID , a.CUSTOMER_CODE
FROM CUSTOMER a, STATUS a1, COUNTRY a2
WHERE a.CUTOMER_STAT = a1.STAT_ID(+)
AND a.COUNTRY_ID = a2.C_ID(+)
ORDER BY lower(trim(CUSTOMER_CODE)) ASC
) row_
)WHERE rownum_ <= 20
AND rownum_ > 0
Now the data returned is in the given order
100 AA
101 AA
119 AA
118 AA
117 AA
116 AA
115 AA
114 AA
113 AA
112 AA
Now with the primary key returned, I fire another query with same sort column
SELECT
a.CUSTOMER_ID , a.CUSTOMER_CODE
FROM CUSTOMER a, STATUS a1, COUNTRY a2
WHERE a.COUNTRY_ID = a1.C_ID(+) AND a.CUTOMER_STAT = a2.STAT_ID(+)
AND (( a.CUSTOMER_ID ) IN ( 100,101,119,118,117,116,115,114,113,112) )
ORDER BY lower(trim(CUSTOMER_7)) ASC
But to my surprise I am getting data in a different order
100 AA
101 AA
112 AA
113 AA
119 AA
115 AA
116 AA
117 AA
118 AA
114 AA
This is causing some issue in our application. What is the reason that we are getting result-set in different order though we have same sort givenwelcome to the forum, going forward if you could please share the create table and insert scripts. Also include you code in tag "{ code }" without quotes and space.
create table country(c_id number, c_name varchar2(30));
insert into country values(1, 'INDIA');
insert into country values(2, 'USA');
insert into country values(3, 'UK');
insert into country values(4, 'JAPAN');
insert into country values(5, 'KOREA');
insert into country values(6, 'AUSTRALIA');
create table status(stat_id number,stat_cd varchar2(30));
insert into status values(1, 'AAA');
insert into status values(2 ,'BBB');
insert into status values(3 ,'CCC');
insert into status values(4 ,'DDD');
insert into status values(5 ,'EEE');
insert into status values(6 ,'FFF');
create table Customer(Customer_ID number,Customer_Name varchar2(30),Customer_code varchar2(30),Country_id number,
Customer_Stat number);
insert into customer values(100, 'Cust_100' ,'AA', 4 ,4);
insert into customer values(101, 'Cust_101' ,'AA' ,5 ,5);
insert into customer values(119, 'Cust_119' ,'AA' ,5 ,5);
insert into customer values(118, 'Cust_118' ,'AA' ,4 ,4);
insert into customer values(117, 'Cust_117' ,'AA' ,3 ,3);
insert into customer values(116, 'Cust_116' ,'AA' ,2 ,2);
insert into customer values(115, 'Cust_115', 'AA' ,1 ,1);
insert into customer values(114, 'Cust_114', 'AA' ,6 ,6);
insert into customer values(113, 'Cust_113', 'AA' ,5 ,5);
insert into customer values(112, 'Cust_112', 'AA' ,4 ,4);
insert into customer values(111, 'Cust_111', 'AA' ,3 ,3);
insert into customer values(110, 'Cust_110', 'AA' ,2, 2);
Your query below has some issues customer_7 there's no column / alias like that, and country table should be a1 and status should be a2 to make sure your query works as column stat_id is not in country and c_id is not in status.
SELECT
a.CUSTOMER_ID , a.CUSTOMER_CODE
FROM CUSTOMER a, STATUS a1, COUNTRY a2
WHERE a.COUNTRY_ID = a1.C_ID(+) AND a.CUTOMER_STAT = a2.STAT_ID(+)
AND (( a.CUSTOMER_ID ) IN ( 100,101,119,118,117,116,115,114,113,112) )
ORDER BY lower(trim(CUSTOMER_7)) ASC
Below changed query,the sort you were performing was on customer_code and I think you were trying to see the data sorted on customer_id. All the customers have some customer_code 'AA'. check out below hope it helps you in understanding.
SELECT *
FROM (SELECT row_.*, ROWNUM rownum_
FROM (SELECT a.customer_id, a.customer_code
FROM customer a, status a1, country a2
WHERE a.customer_stat = a1.stat_id(+)
AND a.country_id = a2.c_id(+)
ORDER BY LOWER (TRIM (customer_id)) ASC) row_)
WHERE rownum_ <= 20 AND rownum_ > 0
SELECT a.customer_id, a.customer_code
FROM customer a, status a2, country a1
WHERE a.country_id = a1.c_id(+)
AND a.customer_stat = a2.stat_id(+)
AND ((a.customer_id) IN
(100, 101, 119, 118, 117, 116, 115, 114, 113, 112)
ORDER BY LOWER (TRIM (customer_id)) ASC
SELECT *
FROM (SELECT row_.*, ROWNUM rownum_
FROM (SELECT a.customer_id, a.customer_code
FROM customer a, status a1, country a2
WHERE a.customer_stat = a1.stat_id(+)
AND a.country_id = a2.c_id(+)
ORDER BY LOWER (TRIM (customer_id)) ASC,customer_code) row_)
WHERE rownum_ <= 20 AND rownum_ > 0
SELECT a.customer_id, a.customer_code
FROM customer a, status a2, country a1
WHERE a.country_id = a1.c_id(+)
AND a.customer_stat = a2.stat_id(+)
AND ((a.customer_id) IN
(100, 101, 119, 118, 117, 116, 115, 114, 113, 112)
ORDER BY LOWER (TRIM (customer_id)) ASC,customer_code -
Returning Records Only for the Current Month
Hello,
I have a query that returns records for the current week and I would like to extend it to return records for the current month.
where TRUNC (START_DATE) < NEXT_DAY (TRUNC (CURRENT_TIMESTAMP) - 1, 'Sat') + 1
AND TRUNC (END_DATE) > NEXT_DAY (TRUNC (CURRENT_TIMESTAMP) - 1, 'Sat') - 7
I have two date fields, the first is called 'Start_Date', the second is called 'End_Date'. I would like the query to return all records for the current month including those that may begin prior to or finish post the month as events can begin in one month and end in another. Does anyone know how this is done in a 'Where Clause'?
Kind Regards,
Steve WelchActually LAST_DAY(ADD_MONTHS(TRUNC(sysdate),-1))+1 gives you the starting day of the current month, and LAST_DAY(TRUNC(sysdate)) gives you the last day of the current month.
So the where be
WHERE TRUNC(START_DATE) >= LAST_DAY(ADD_MONTHS(TRUNC(sysdate),-1))+1 OR TRUNC(END_DATE) <= LAST_DAY(TRUNC(sysdate))
Start Date >= 1st Day of Month OR End Date <= Last Day of Month, meaning either date is within the current month.
Maybe you are looking for
-
Menu/submenu managing and Event Listening problem
Hi guys, I'm creating a flashwebsite and I've got a problem with submenu appearing/disappering. What is extremely easy in html/jquery is taking me overburned in actiuonscript: make appear a submenu only when the mouse cursor is over its button and no
-
I finally realized that I can force the iPhone to use the server's Trash and Sent folder and am VERY pleased with this. Unfortunately, now I have extra folders on my iPhone--they don't show up on my IMAP server from what I see. It seems that the draf
-
Assigning Multiple users as requestor of PR in workflow
Dear Friends, We are using standard workflow for PR releasing. In our process the requestor needs to approve as 1st level. We defined presently defined one user as requestor in table SPRO>>Materials Management>>Purchasing>>Purchase Requisition>>Relea
-
Security on Nokia 6730 Classic
Hello, I have a Nokia 6730C and every time i want to start an external software for GPS (the software is instamapper, is a free software to control the possition of the mobile by web) the question is, There is any option to eliminate the warning from
-
Will an iTunes download work???
I REALLY want to purchase the new Nike Sport Music Endurance I. In reading the reviews, I am a little confused. Am I understanding correctly that the music will play on my shuffle, but the actual training/coaching will not. My husband seems to think