Simple query-To change value of UI if the value of other UI element changes
Hi Experts,
In the WD Screen. there are two fields called Start Date1 and Start Date2. User initally enters Start Date1. The value of Start Date2 get populated. It becomes same as Star Date1
The user enter other details and data is processed.It caters the basic requirement
We have another requirement here - The user may change the Start Date1 and if he does so Start Date2 should also get changed and should become same as modified Start Date1.
How we can do so?
Regards,
Gary
Hi,
If you created value attributes for your input fields suppose va_startDate1 and va_startDate2.
Then in the onenter of first startdate1 write the following code. it will populate the same date in the startdate2 i/p field.
Date startDate1 = wdContext.currentContextElement().getVa_startDate1();
wdContext.currentContextElement().setVa_startDate2(startDate1);
Now as user will press enter on startdate1 then same value will be there in the second field.
I hope it helps.
Regards,
Rohit
Similar Messages
-
Using Powershell Script Run simple query in MS Access 2007 and export the results of query to Excel
Hi Experts,
I have a Access 2007 DB file and 2 Big tables inside that (bigger than the size that can be easily handled by MS Excel 2007).
My requirement is automate using powershell scripts the below things.
1. Create a SQL query in Access DB and save that in access DB
2. Run the saved query and export the result in excel sheet where I can create the charts and Pivots. Thanks in advance
PrajeshDo you have to use the Access query, couldn't you just recreate the query in Powershell? Here's a link with good info that references an existing script for querying an Access database:
http://blogs.technet.com/b/heyscriptingguy/archive/2009/08/13/hey-scripting-guy-can-i-query-a-microsoft-access-database-with-a-windows-powershell-script.aspx
Once you have your dataset you can pipe it to
Export-Csv -NoType c:\pathtofile\output.csv -
Simple Query working on 10G and not working on 11gR2 after upgrade
Hi Folks,
This is the first time i am posting the query in this Blog.
I have a small issue which preventing the UAT Sigoff.
Simple query working fine on 10.2.0.1 and after upgrade to 11.2.0.1 its error out
10.2.0.4:
=====
SQL> SELECT COUNT(*) FROM APPS.HZ_PARTIES HP WHERE ATTRIBUTE_CATEGORY= 'PROPERTY' AND ATTRIBUTE1=1;
COUNT(*)
1
SQL> SELECT COUNT(*) FROM APPS.HZ_PARTIES HP WHERE ATTRIBUTE_CATEGORY= 'PROPERTY' AND ATTRIBUTE1=00001;
COUNT(*)
1
SQL> select ATTRIBUTE1 FROM APPS.HZ_PARTIES HP WHERE ATTRIBUTE_CATEGORY= 'PROPERTY' AND ATTRIBUTE1=1;
ATTRIBUTE1
00001
11.2.0.1:
=====
SQL> SELECT COUNT(*) FROM APPS.HZ_PARTIES HP WHERE ATTRIBUTE_CATEGORY= 'PROPERTY' AND ATTRIBUTE1=1
ERROR at line 1:
ORA-01722: invalid number
SQL> SELECT COUNT(*) FROM APPS.HZ_PARTIES HP WHERE ATTRIBUTE_CATEGORY= 'PROPERTY' AND ATTRIBUTE1=00001
ERROR at line 1:
ORA-01722: invalid number
SQL> select ATTRIBUTE1 FROM APPS.HZ_PARTIES HP WHERE ATTRIBUTE_CATEGORY= 'PROPERTY' AND ATTRIBUTE1='1';
no rows selected
SQL> SELECT COUNT(*) FROM APPS.HZ_PARTIES HP WHERE ATTRIBUTE_CATEGORY= 'PROPERTY' AND ATTRIBUTE1='00001';
COUNT(*)
1
SQL> select ATTRIBUTE1 FROM APPS.HZ_PARTIES HP WHERE ATTRIBUTE_CATEGORY= 'PROPERTY' AND ATTRIBUTE1='00001';
ATTRIBUTE1
00001
++++++++++++++++++++++++++++++++++++++++++++++
SQL > desc APPS.HZ_PARTIES
Name Type
======== ======
ATTRIBUTE1 VARCHAR2(150)
++++++++++++++++++++++++++++++++++++++++++++++
Changes:
Recently i upgraded the DB from 10.2.0.4 to 11.2.0.1
Query:
1.If the type of that row is VARCHAR,why it is working in 10.2.0.4 and why not working in 11.2.0.1
2.after upgrade i analyzed the table with "analyze table " query for all AP,AR,GL,HR,BEN,APPS Schemas--Is it got impact if we run analyze table.
Please provide me the answer for above two questions or refer the document is also well enough to understand.Based on the Answer client will sigoff to-day.
Thanks,
P KumarWhiteHat wrote:
the issue has already been identified: in oracle versions prior to 11, there was an implicit conversion of numbers to characters. your database has a character field which you are attempting to compare to a number.
i.e. the string '000001' is not in any way equivalent to the number 1. but Oracle 10 converts '000001' to a number because you are asking it to compare to the number you have provided.
version 11 doesn't do this anymore (and rightly so).
the issue is with the bad code design. you can either: use characters in the predicate (where field = 'parameter') or you can do a conversion of the field prior to comparing (where to_num(field) = parameter).
I would suggest that you should fix your code and don't assume that '000001' = 1I don't think that the above is completely correct, and a simple demonstration will show why. First, a simple table on Oracle Database 10.2.0.4:
CREATE TABLE T1(C1 VARCHAR2(20));
INSERT INTO T1 VALUES ('1');
INSERT INTO T1 VALUES ('0001');
COMMIT;A select from the above table, relying on implicit data type conversion:
SELECT
FROM
T1
WHERE
C1=1;
C1
1
0001Technically, the second row should not have been returned as an exact match. Why was it returned, let's take a look at the actual execution plan:
SELECT
FROM
TABLE(DBMS_XPLAN.DISPLAY_CURSOR(NULL,NULL,NULL));
SQL_ID g6gvbpsgj1dvf, child number 0
SELECT * FROM T1 WHERE C1=1
Plan hash value: 3617692013
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | | | 2 (100)| |
|* 1 | TABLE ACCESS FULL| T1 | 2 | 24 | 2 (0)| 00:00:01 |
Predicate Information (identified by operation id):
1 - filter(TO_NUMBER("C1")=1)
Note
- dynamic sampling used for this statementNotice that the VARCHAR2 column was converted to a NUMBER, so if there was any data in that column that could not be converted to a number (or NULL), we should receive an error (unless the bad rows are already removed due to another predicate in the WHERE clause). For example:
INSERT INTO T1 VALUES ('.0001.');
SELECT
FROM
T1
WHERE
C1=1;
SQL> SELECT
2 *
3 FROM
4 T1
5 WHERE
6 C1=1;
ERROR:
ORA-01722: invalid numberNow the same test on Oracle Database 11.1.0.7:
CREATE TABLE T1(C1 VARCHAR2(20));
INSERT INTO T1 VALUES ('1');
INSERT INTO T1 VALUES ('0001');
COMMIT;
SELECT
FROM
T1
WHERE
C1=1;
C1
1
0001
SELECT
FROM
TABLE(DBMS_XPLAN.DISPLAY_CURSOR(NULL,NULL,NULL));
SQL_ID g6gvbpsgj1dvf, child number 0
SELECT * FROM T1 WHERE C1=1
Plan hash value: 3617692013
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | | | 2 (100)| |
|* 1 | TABLE ACCESS FULL| T1 | 2 | 24 | 2 (0)| 00:00:01 |
Predicate Information (identified by operation id):
1 - filter(TO_NUMBER("C1")=1)
Note
- dynamic sampling used for this statement
INSERT INTO T1 VALUES ('.0001.');
SELECT
FROM
T1
WHERE
C1=1;
SQL> SELECT
2 *
3 FROM
4 T1
5 WHERE
6 C1=1;
ERROR:
ORA-01722: invalid numberAs you can see, exactly the same actual execution plan, and the same end result.
The OP needs to determine if non-numeric data now exists in the column. Was the database characterset possibly changed during/after the upgrade?
Charles Hooper
Co-author of "Expert Oracle Practices: Oracle Database Administration from the Oak Table"
http://hoopercharles.wordpress.com/
IT Manager/Oracle DBA
K&M Machine-Fabricating, Inc. -
Simple query takes 18 minutes to retrieve data....
Hi,
I am facing this problem at the customer site where a simple query on a table takes 18 minutes or more. Please find below the details.
Table Structure
CREATE TABLE dsp_data
quantum_id NUMBER(11) NOT NULL,
src NUMBER(11) NOT NULL,
call_status NUMBER(11) NOT NULL,
dst NUMBER(11) NOT NULL,
measurement_id NUMBER(11) NOT NULL,
is_originating NUMBER(1) NOT NULL,
measurement_value NUMBER(15,4) NOT NULL,
data_type_id NUMBER(3) NOT NULL,
data VARCHAR2(200) NOT NULL
TABLESPACE dsp_data_tspace
STORAGE (PCTINCREASE 0 INITIAL 100K NEXT 1024K)
PARTITION BY RANGE (quantum_id)
(PARTITION dsp_data_default VALUES LESS THAN (100));
CREATE INDEX dsp_data_idx ON dsp_data
quantum_id,
src,
call_status,
dst,
measurement_id,
is_originating,
measurement_value,
data_type_id
TABLESPACE dsp_data_idx_tspace
LOCAL;
CREATE INDEX dsp_data_src_idx ON dsp_data
src
TABLESPACE dsp_data_idx_tspace
LOCAL;
CREATE INDEX dsp_data_dst_idx ON dsp_data
dst
TABLESPACE dsp_data_idx_tspace
LOCAL;
ALTER TABLE dsp_data
ADD CONSTRAINT fk_dsp_data_1
FOREIGN KEY
quantum_id
REFERENCES mds_measurement_intervals
quantum_id
ALTER TABLE dsp_data
ADD CONSTRAINT fk_dsp_data_2
FOREIGN KEY
data_type_id
REFERENCES mds_drilldown_types
type_id
ALTER TABLE dsp_data
ADD CONSTRAINT pk_dsp_data
PRIMARY KEY
quantum_id,
src,
call_status,
dst,
measurement_id,
is_originating,
measurement_value,
data_type_id,
data
USING INDEX
TABLESPACE dsp_data_idx_tspace
LOCAL;
Table Space Creation
All table space creation is done using following command
CREATE TABLESPACE [tablespaceName]
DATAFILE [tablespaceDatafile] SIZE 500M REUSE
AUTOEXTEND ON NEXT 10240K
DEFAULT STORAGE ( INITIAL 1024K
NEXT 1024K
MINEXTENTS 10
MAXEXTENTS UNLIMITED
PCTINCREASE 0
Server Configuration on CUtsomer Site
(1) 2 x Dual PA8900 Proc = 4GHz
(2) RAM = 16GB
(3) 3 x Internal HDDs
(4) 1 x External MSA-30 storage array (oracle db)
Record Information On Customer Site
select count(*) from dsp_data;
COUNT(*)
181931197
select min (quantum_id) from dsp_data where dst=2;
This takes 18 minutes or more....
SQL> SQL> SQL> explain plan for select min (quantum_id) from dsp_data where dst=2;
Explained.
SQL> @?/rdbms/admin/utlxpls
PLAN_TABLE_OUTPUT
Plan hash value: 999040277
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |
| 0 | SELECT STATEMENT | | 1 | 14 | 1 (0)| 00:00:01 | | |
| 1 | SORT AGGREGATE | | 1 | 14 | | | | |
| 2 | FIRST ROW | | 92 | 1288 | 1 (0)| 00:00:01 | | |
| 3 | PARTITION RANGE ALL | | 92 | 1288 | 1 (0)| 00:00:01 | 1 | 29 |
|* 4 | INDEX FULL SCAN (MIN/MAX)| DSP_DATA_IDX | 92 | 1288 | 1 (0)| 00:00:01 | 1 | 29 |
As mentioned above the query takes 18 minutes or more. This is a critical issue at customer. Can you please give your suggestions how to improve and reduce the query time. Thanks in advance.Hi,
I did the following changes in the indexes of table.
drop index DSP_DATA_IDX;
create index DSP_DATA_MEASUREMENT_ID_IDX on DSP_DATA (MEASUREMENT_ID) TABLESPACE dsp_data_idx_tspace LOCAL;
After that I did explain plan,
explain plan for select min(QUANTUM_ID) from mds.DSP_DATA where SRC=11;
PLAN_TABLE_OUTPUT
| Id | Operation | Name | Rows | Bytes | Cost (%CPU
| 0 | SELECT STATEMENT | | 1 | 11 | 3 (0
| 1 | SORT AGGREGATE | | 1 | 11 |
| 2 | FIRST ROW | | 430K| 4626K| 3 (0
| 3 | PARTITION RANGE ALL | | 430K| 4626K| 3 (0
| 4 | INDEX FULL SCAN (MIN/MAX)| PK_DSP_DATA | 430K| 4626K| 3 (0
Note
- 'PLAN_TABLE' is old version
14 rows selected
SELECT table_name, index_name, monitoring, used FROM v$object_usage;
TABLE_NAME INDEX_NAME MONITORING USED
DSP_DATA DSP_DATA_SRC_IDX YES NO
It seems that DSP_DATA_SRC_IDX is not getting used in query. What changes do i need to make so that DSP_DATA_SRC_IDX index gets used.
Also, you have stated that to create global index on src and dst. How do i create them.
Thanks in Advance.
Edited by: 780707 on Jul 8, 2010 11:58 PM -
Hello, I'll start by saying that I am a noob. Anyways, I am trying to do what I thought would be a simple query to get records that are greater than or equal to the current date: this is my query...
<cfquery name="getUpcoming" datasource="events">
SELECT title, eventDate FROM event WHERE eventDate >= #Now()# ORDER BY eventDate ASC
</cfquery>
It works, sort of, I do get records that are greater than the current date, but any records that are equal to do not show up.
I am assuming that it is looking at time as well, or I am doing it completely wrong. I don't know? Any help would be greatly appreciated.I didn't use the cfqueryparam as suggested, is there something dangerous about doing it this way?
Nothing dangerous, no. Just "less than ideal" (in a sloppy / lazy sort of way). As I suggested, one should not hard-code dynamic values into the SQL string, one should pass them as parameters. it's just "the way it should be done".
When the DB receives your SQL string (with the dynamic values hard-coded), the DB engine needs to compile the SQL to make an execution plan before executing the query. Any change to the SQL string requires recompilation. However if you pass your parameter as parameters, then the SQL does not need to be recompiled.
It's the same sort of thing as not using global variables unless one has to, despite the fact they're "easier", or duplicating code instead of refactoring code. One should try to write decent code.
Adam -
Query to get values based on a date range.
11g.
Hi there,
I have a simple requirement(hopefully).
I have a parameter which is basically a count range which when I pass the sql query should fetch the values from a column falling in that range.
My table is item details
Item cost
item1 1
item2 10
item3 20
item4 3
.I have a parameter which I have to pass to this query where items are listed based on the cost.
So I want to select items which cost between 0 -10, 11-20, 21-30 and 31-40
Now I am using Apex to show the count report like
0-10 11- 20 21- 30 31- 40
3 2 0 0
The numbers are hyperlinked and I pass the parameters based on which another report shows the details. So if the user clicks on number 3 in the report. The underlying query would be something like
select * from item_Details where cost between 0 and 10.So I was wondering how do pass the parameter to the sql in the best possible way to get the costs based on the range?
Maybe the parameters should be some code which can be decoded in the SQL?
Any help or suggestions please?
Thanks,
RyanHi,
Try this to pass the parameter in the query...
select * from item_Details where cost between to_number(substr('0-10',0,instr('0-10','-')-1)) and to_number(substr('0-10',instr('0-10','-')+1,length('0-10'));
Regards,
Niha -
Simple query takes time to run
Hi,
I have a simple query whcih takes about 20 mins to run.. here is the TKPROF forit:
SELECT
SY2.QBAC0,
sum(decode(SALES_ORDER.SDCRCD,'USD', SALES_ORDER.SDAEXP,'CAD', SALES_ORDER.SDAEXP /1.0452))
FROM
JDE.F5542SY2 SY2,
JDE.F42119 SALES_ORDER,
JDE.F0116 SHIP_TO,
JDE.F5542SY1 SY1,
JDE.F4101 PRODUCT_INFO
WHERE
( SHIP_TO.ALAN8=SALES_ORDER.SDSHAN )
AND ( SY1.QANRAC=SY2.QBNRAC and SY1.QAOTCD=SY2.QBOTCD )
AND ( PRODUCT_INFO.IMITM=SALES_ORDER.SDITM )
AND ( SY2.QBSHAN=SALES_ORDER.SDSHAN )
AND ( SALES_ORDER.SDLNTY NOT IN ('H ','HC','I ') )
AND ( PRODUCT_INFO.IMSRP1 Not In (' ','000','689') )
AND ( SALES_ORDER.SDDCTO IN ('CO','CR','SA','SF','SG','SP','SM','SO','SL','SR') )
AND (
( SY1.QACTR=SHIP_TO.ALCTR )
AND ( PRODUCT_INFO.IMSRP1=SY1.QASRP1 )
GROUP BY
SY2.QBAC0
call count cpu elapsed disk query current rows
Parse 1 0.07 0.07 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 10 92.40 929.16 798689 838484 0 131
total 12 92.48 929.24 798689 838484 0 131
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
Parsing user id: 62
Rows Row Source Operation
131 SORT GROUP BY
3535506 HASH JOIN
4026100 HASH JOIN
922 TABLE ACCESS FULL OBJ#(187309)
3454198 HASH JOIN
80065 INDEX FAST FULL SCAN OBJ#(30492) (object id 30492)
3489670 HASH JOIN
65192 INDEX FAST FULL SCAN OBJ#(30457) (object id 30457)
3489936 PARTITION RANGE ALL PARTITION: 1 9
3489936 TABLE ACCESS FULL OBJ#(30530) PARTITION: 1 9
97152 TABLE ACCESS FULL OBJ#(187308)
OVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS
call count cpu elapsed disk query current rows
Parse 1 0.07 0.07 0 0 0 0
Execute 2 0.00 0.00 0 0 0 0
Fetch 10 92.40 929.16 798689 838484 0 131
total 13 92.48 929.24 798689 838484 0 131
Misses in library cache during parse: 1kindly suggest how to resolve this...
OS is windows and its 9i DB...
Thanks> ... you want to get rid of the IN statements.
They prevent Oracle from usering the index.
SQL> create table mytable (id,num,description)
2 as
3 select level
4 , case level
5 when 0 then 0
6 when 1 then 1
7 else 2
8 end
9 , 'description ' || to_char(level)
10 from dual
11 connect by level <= 10000
12 /
Table created.
SQL> create index i1 on mytable(num)
2 /
Index created.
SQL> exec dbms_stats.gather_table_stats(user,'mytable')
PL/SQL procedure successfully completed.
SQL> set autotrace on explain
SQL> select id
2 , num
3 , description
4 from mytable
5 where num in (0,1)
6 /
ID NUM DESCRIPTION
1 1 description 1
1 row selected.
Execution Plan
Plan hash value: 2172953059
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 5001 | 112K| 2 (0)| 00:00:01 |
| 1 | INLIST ITERATOR | | | | | |
| 2 | TABLE ACCESS BY INDEX ROWID| MYTABLE | 5001 | 112K| 2 (0)| 00:00:01 |
|* 3 | INDEX RANGE SCAN | I1 | 5001 | | 1 (0)| 00:00:01 |
Predicate Information (identified by operation id):
3 - access("NUM"=0 OR "NUM"=1)Regards,
Rob. -
How I can delete a row using a simple query?
SZSLIFE_SPRIDEN_PIDM SZSLIFE_SGBSTDN_TERM_CODE_EFF SZSLIFE_SLRRASG_BLDG_CODE SZSLIFE_SLRRASG_ROOM_NUMBER SZSLIFE_SLRRASG_BEGIN_DATE SZSLIFE_SLRRASG_END_DATE
48547 199890
48547 199990
48547 199990 BLU 205 09/03/1999 12/23/1999
48547 200010
48547 200010 BLU 205 01/25/2000 05/25/2000
48547 200090
48547 200090 MOR 406 09/03/2000 12/23/2000
48547 200110
48547 200110 MOR 406 01/25/2001 05/25/2001
48547 200190
48547 200210
48547 200290
48547 200310
48547 200390
48547 200410
48547 200610
Here is what a simple question is probably for some of you; I can not get this to work. I need to delete all the rows that are duplicate like row #2 with the same SZSLIFE_SGBSTDN_TERM_CODE_EFF but with not
SZSLIFE_SLRRASG_BLDG_CODE and SZSLIFE_SLRRASG_ROOM_NUMBER
I need to write a code where it counts the SZSLIFE_SGBSTDN_TERM_CODE_EFF and if it have the same (2 times.
I need to delete the row without SZSLIFE_SLRRASG_BLDG_CODE and SZSLIFE_SLRRASG_ROOM_NUMBER
The SZSLIFE_SLRRASG_BLDG_CODE NEEDS to be not null, because I do an insert in this table I need to be able to insert null values.
How I can use a simple query where I can delete all the duplicate records without bldg_code and room number…
Here is the table description
SZSLIFE_SPRIDEN_PIDM NUMBER(8)
SZSLIFE_SPRIDEN_ID VARCHAR2(10)
SZSLIFE_SPRIDEN_LAST_NAME VARCHAR2(60)
SZSLIFE_SPRIDEN_FIRST_NAME VARCHAR2(60)
SZSLIFE_SPRIDEN_MI VARCHAR2(15)
SZSLIFE_SGBSTDN_TERM_CODE_EFF VARCHAR2(6)
SZSLIFE_SGBSTDN_STST_CODE VARCHAR2(2)
SZSLIFE_STVSTST_DESC VARCHAR2(30)
SZSLIFE_SGBSTDN_STYP_CODE VARCHAR2(2)
SZSLIFE_STVSTYP_DESC VARCHAR2(30)
SZSLIFE_SGBSTDN_LEVL_CODE VARCHAR2(2)
SZSLIFE_STVLEVL_DESC VARCHAR2(30)
SZSLIFE_SGBSTDN_RESD_CODE VARCHAR2(10)
SZSLIFE_STVRESD_DESC VARCHAR2(40)
SZSLIFE_SLRRASG_BLDG_CODE VARCHAR2(10)
SZSLIFE_SLRRASG_ROOM_NUMBER VARCHAR2(10)
SZSLIFE_SLRRASG_BEGIN_DATE VARCHAR2(12)
SZSLIFE_SLRRASG_END_DATE VARCHAR2(12)
SLRRASG_ASCD_CODE VARCHAR2(2)
I will appreciate any help!
SLRRASG_ROLL_IND VARCHAR2(2)Thank you very much Sandeep, this works!
1 DELETE SZSLIFE_TEMP2
2 WHERE
3 SZSLIFE_SGBSTDN_TERM_CODE_EFF
4 IN
5 (SELECT SZSLIFE_SGBSTDN_TERM_CODE_EFF
6 FROM SZSLIFE_TEMP2
7 GROUP BY
8 SZSLIFE_SGBSTDN_TERM_CODE_EFF
9 HAVING COUNT(*) > 1)
10 AND
11* SZSLIFE_SLRRASG_BLDG_CODE = ' '
12 /
4 rows deleted.
The only thing here is that the SZSLIFE_SLRRASG_BLDG_CODE can not be defined as a a NULL, so I can not use
where SZSLIFE_SLRRASG_BLDG_CODE is null
Here is how those two columns are define:
SZSLIFE_SLRRASG_BLDG_CODE VARCHAR2(10)
SZSLIFE_SLRRASG_ROOM_NUMBER VARCHAR2(10)
So,
my question is it will be safe to do SZSLIFE_SLRRASG_BLDG_CODE = ' ' ?
Again, it works, it deleted the rfows that I wanted...
Thank you very much!!!
Rogelio -
consider this situation,
Two or more productid will be accquired by same customerid, by same shipvia, on the same day of the week of shipped date. i want the simple query for this.
my tables are from northwind:
[orders] = OrderID, CustomerID, EmployeeID, OrderDate, RequiredDate, ShippedDate, ShipVia, Freight, ShipName, ShipAddress, ShipCity, ShipRegion, ShipPostalCode, ShipCountry.
[orders details] = OrderID, ProductID, UnitPrice, Quantity, Discount.
i tried some but it is not exact, it gives wrong result.
select pd.CustomerID,pd.ProductID, pd.no_of_time_purchased, sd.ShipVia, sd.same_ship_count, shipped_day from
select ProductID,o.CustomerID,COUNT(productid) as no_of_time_purchased
from orders o join [Order Details] od on o.OrderID=od.OrderID group by ProductID,o.CustomerID
having count(od.ProductID) >1) pd
join
(select OrderID,customerid, shipvia, count(shipvia)as same_ship_count, DATENAME(DW,ShippedDate)as shipped_day from orders
group by customerid, ShipVia, ShippedDate having COUNT(ShipVia) > 1 ) sd
on sd.CustomerID=pd.CustomerIDHi,
I think I have a solution that will at least give you a clue how to go about it. I have simplified the tables you mentioned and created them as temporary tables on my side, with some fake data to test with. I have incldued the generation of these temporary
tables for your review.
In my example I have included:
1. A customer which has purchased the same product on the same day, using the same ship 3 times,
2. Another example the same as the first but the third purchase was on a different day
3. Another example the same as the first but the third purchase was a different product
4. Another example the same as the first but the third purchase was using a different "ShipVia".
You should be able to see that by grouping on all of the columns that you wich to return, you should not need to perform any subselects.
Please let me know if I have missed any requirements.
Hope this helps:
CREATE TABLE #ORDERS
OrderID INT,
CustomerID INT,
OrderDate DATETIME,
ShipVia VARCHAR(5)
CREATE TABLE #ORDERS_DETAILS
OrderID INT,
ProductID INT,
INSERT INTO #ORDERS
VALUES
(1, 1, GETDATE(), 'ABC'),
(2, 1, GETDATE(), 'ABC'),
(3, 1, GETDATE(), 'ABC'),
(4, 2, GETDATE() - 4, 'DEF'),
(5, 2, GETDATE() - 4, 'DEF'),
(6, 2, GETDATE() - 5, 'DEF'),
(7, 3, GETDATE() - 10, 'GHI'),
(8, 3, GETDATE() - 10, 'GHI'),
(9, 3, GETDATE() - 10, 'GHI'),
(10, 4, GETDATE() - 10, 'JKL'),
(11, 4, GETDATE() - 10, 'JKL'),
(12, 4, GETDATE() - 10, 'MNO')
INSERT INTO #ORDERS_DETAILS
VALUES
(1, 1),
(2, 1),
(3, 1),
(4, 2),
(5, 2),
(6, 2),
(7, 3),
(8, 3),
(9, 4),
(10, 5),
(11, 5),
(12, 5)
SELECT * FROM #ORDERS
SELECT * FROM #ORDERS_DETAILS
SELECT
O.CustomerID,
OD.ProductID,
O.ShipVia,
COUNT(O.ShipVia),
DATENAME(DW, O.OrderDate) AS [Shipped Day]
FROM #ORDERS O
JOIN #ORDERS_DETAILS OD ON O.orderID = OD.OrderID
GROUP BY OD.ProductID, O.CustomerID, O.ShipVia, DATENAME(DW, O.OrderDate) HAVING COUNT(OD.ProductID) > 1
DROP TABLE #ORDERS
DROP TABLE #ORDERS_DETAILS -
Help! no response when doing SIMPLE query!
I meet a strange problem when I do a SIMPLE query on a table in Oracle 8.1.7, just like:
SELECT id FROM person WHERE id='12345';
Most of id values are ok to the query, except some values.
Whether I use these values in sqlplus or JDBC, mostly, no response is returned!! And I find the session in Oracle always keeps the status 'Active'. But in few scenario I can get the result quickly.
I don't know the reason. Help me please!
Thanks a lot!
MeyorI'm not sure if the 'id' column contains something else.
When I shutdown and restart the database, the problem seems to be "solved". If the problem reoccurs again, I will try to use xTRIM functions.
Thanks!
Meyor -
Refreshing Hierarchy node variable in BEx query with change in hierarchy
Hi all,
We have used a hierarchy node variable on Characteristic ZECCSAC (user-defined) and used it in a BEx query with default value set to a particular node value. Upto this, it is working fine.
The hierarchy used in the query, with the hierarchy node variable, was later changed ( and in future it can undergo changes ). Since the number of records in the hierarchy are changing, the nodenames of the hierarchy nodes are changing. But the hier node variable default value is still set to the earlier nodename for that node description. So at runtime it is giving an error "ECCS Account Number is invalid"!
Can anyone suggest how to refresh a hierarchy node variable default value each time a query is run so that the latest nodename is always taken ?
Quick reply will be appreciated.
ThanksHi,
You get this with User exits.
Thnaks -
On change one value of UDF, value of other UDF should be change
Hi to all,
I have set formatted search on A/R Invoice Form, there is two udf one is BillFrom and second is Jurisdiction. On change of BillFrom the value of the udf should be replace in Jurisdiction. I have write below given query for the same. It is working fine in update mode of existing records. Till time working fine in new record add mode too. Since last 3 days it is not working in add mode.
Query :
SELECT case when $[oinv.U_BillFrom] = 'BLR' then 'Bangalore'
when $[oinv.U_BillFrom] = 'MUM' then 'Mumbai'
when $[oinv.U_BillFrom] = 'GNR' then 'Gandhinagar'
when $[oinv.U_BillFrom] = 'DLH' then 'Delhi'
end
from OINV
where OINV.DocNum = $[OINV.DocNum]
Can i have your expert advice to resolve the issue.
With Warm Regards,
Chintesh SoniChintesh,
How does INV1 factor in the query? That has not been mentioned in your post.
When does the query run? What field is the query assigned to?
I can only guess at the issues if you don't give me complete information.
Remember you cannot mass update child records from the parent record via a formatted search.
If you assign this search to field in OINV and link it to oinv.U_BillForm it will work:
SELECT case when $[oinv.U_BillFrom] = 'BLR' then 'Bangalore'
when $[oinv.U_BillFrom] = 'MUM' then 'Mumbai'
when $[oinv.U_BillFrom] = 'GNR' then 'Gandhinagar'
when $[oinv.U_BillFrom] = 'DLH' then 'Delhi'
end
You don't need the docnum logic at all. Remove it.
If you are trying to change the values in the matrix based on the oinv.U_Billform changing it will NOT work. To do this you must use the SDK or the SBO_SP_TransasctionNotification. -
Creating a Query to Change Price
Hi,
I have created a query to change the price in the Sales Order that looks like:
SELECT CASE A WHEN COND1 THEN 120.0 ELSE $[$38.17] END FOR BROWSE
This means, when A <> COND1 I want the existing price ($[$38.17])to be maintained (no modification). And, I want to modify the price to 120.0 only when A=COND1.
However, the above query results in the price getting modified to its own value when A <> COND1 and sales order identifying this as a field value change; and, the OK button changes to Update.
To avoid this, is there a way to write a query such that price field is left untouched when A <> COND1?
Thanks.Hi Satish,
I think I found a solution to this problem. It might look as a tedious solution, but I think it will work. Try the following:
declare @Val varchar(10)
select @val = CASE A WHEN COND1 THEN 120.0 end
if @val is not null
select @val
I have managed with this to get the result I think you are looking for. Certain documents will update and on others it will only select a result if the value is not null.
Hope it helps,
Adele -
Fiscal Year Period - Query Designer - Characteristics Value
Hi Experts,
In query designer, characteristics value for 0FISCPER by default shows value of fiscal year variant V9. But for Fiscal year variant V9, 002.2014 is November 2013.
Now user want to display the correct period and its description (002.2014 is February 2014) which implies need to use different variant. Please let me how this can be changed.
Regards
Suresh KumarHi Suresh,
Try this
Path: Financial Accounting >> Financial Accounting Global settings >> Fiscal Year >> maintain Fiscal year variant (maintain shortened fiscal year)
Transaction Code: OB29
Regards,
Amit -
SSAS source Query, Simple Query with never ending refresh time.
Hello...
A very simple query based on SSAS cube do not give answer. :-(
I start a trace to see the exact mdx statement transmited to SSAS, run it in a query editor, the result is... immediate !
Is there any clue to explain such a behavior ? cube meta data definition ?
Any help is welcome
===========
Version: 2.21.3974.242hello,
find below the capture of the trace, cannot see any references to rowsets either cellsets...
thank you for your help
select{[Measures].[Fact Count]}on 0,nonempty(crossjoin([Invoice Attributes].[Scenario].[Scenario].allmembers,[Period Date].[Month].[Month].allmembers,[Period Date].[Quarter].[Quarter].allmembers,[Period Date].[Year].[Year].allmembers,[Product Line Techno].[Product
Line Code].[Product Line Code].allmembers),{[Measures].[Fact Count]})properties member_caption,member_unique_name on 1 from(select([Invoice Attributes].[Scenario].&[ACTUALS],[Period Date].[Month].&[20150101],[Product Line Techno].[Product Line Code].&[EB])on
0 from [Revenue Detailed])cell properties value
<PropertyList xmlns="urn:schemas-microsoft-com:xml-analysis">
<Catalog>OLAP12</Catalog>
<SspropInitAppName>Microsoft SQL Server Management Studio - Query</SspropInitAppName>
<LocaleIdentifier>1036</LocaleIdentifier>
<ClientProcessID>5992</ClientProcessID>
<Format>Native</Format>
<AxisFormat>TupleFormat</AxisFormat>
<Content>SchemaData</Content>
<Timeout>0</Timeout>
<DbpropMsmdActivityID>284bd120-34f1-4fac-83cb-e8cf443261ad</DbpropMsmdActivityID>
<DbpropMsmdRequestID>f11764e9-b092-41ea-aae6-a91763960eae</DbpropMsmdRequestID>
</PropertyList>
Maybe you are looking for
-
Images open in wrong version of Photoshop
I have both Photoshop CC and Photoshop CC 2014 installed because some actions I have purchased only work in Photoshop CC due to them using the Oil Painting filter. But if I double click an image to open it, it opens in Photoshop CC. So I right click
-
Trackpoint scrolling not working in Safari
I have an x61s running Windows Vista business (32 bit). Problem is the trackpoint scrolling feature not working in Apple web browser Safari. Somewhere on the web I found instructions for fixing this by editing file tp4table.dat located in c:/windows/
-
SLOW IMAIL SINCE INSTALLING MAVERICK
I have read through several comments and don't see a solution. My phone will register emails and there's nothing I can do to get it to come into my computer imail, it just comes in slowly on its own. It is extremely frustrating.
-
Can i get all statemnts analysys in a procedure when i run statspack
Hi, I am running statspack to findout sql staements which are taking long time.I have some procedures too to analyze.can i get statistics for all statements within the procedures indivisually or i will get only overall statistics for that peocedure.i
-
My Mac's Built in iSight is not showing all the options for the camera
On Flash bashed chat rooms such as Stickam and Tinychat, my camera doesn't respond but when I right click>settings >Camera the drop down box only shows one option (Built-in iSight) when it usually shows three (Built in iSight, USB Class Video and Som