Answers Reports with Aggregate Function
Hi,
I have a Product Table with columns, CustomerName, ProductID,ProductName,Purchase Date. I am trying to create a report in the flg. format:
CustomerName Customer-Prod Count ProductName Total Prod Count %of Products
Mike 10 CD 2 20%
DVD 1 10%
Computer 6 60%
Laptop 1 10%
Dan 5 Computer 3 60%
DVD 2 40%
Any suggestions on how to accomplish this?
Thanks,
rkingmdu
Thanks, the syntax worked. But I get incorrect results.
Here's what I queried:
"PRODUCTS".CUSTOMERNAME,
COUNT("PRODUCTS"."PRODUCTID" By "PRODUCTS"."CUSTOMERNAME"),
"PRODUCTS".PRODUCTNAME,
COUNT("PRODUCTS"."PRODUCTID" By "PRODUCTS"."PRODUCTID", "PRODUCTS"."CUSTOMERNAME")
The first count returns the correct results but the second count is wrong. The query looks to be ok, I don't know where I am getting it wrong.
Any ideas?
Thanks
rkingmdu
Similar Messages
-
Problem with aggregate function
Hello,
the prerequisite is to have a table with the following columns (#id, a_date).
Now the task is to select the maximum date from a range of rows of this table
select max(t.a_date)
from the_table t
where <condition to get only some rows of the_table>
and to get the id of the record which holds the maximum date. That's where the problem is located. It should look like the following code (yes, I know this cannot work because grouping by the id makes the aggregate senseless) just to make clear what I want to do.
select max(t.a_date), t.id
from the_table t
where <condition to get only some rows of the_table>
group by t.id
Does anybody have any idea how to solve the problem?
With regards,
Cosima
Message was edited by:
Cosima LaubeHi all,
as the condition in the where-clause is very complex, I decided to use the solution with the FIRST function. After googling and reading a bit, I have just two more questions for my deeper understanding:
1) am I right that both snippets below do exactly the same?
SELECT MAX (t.a_date)
, MAX (t.ID)KEEP (DENSE_RANK FIRST ORDER BY t.a_date DESC)
FROM the_table t
WHERE <condition to get only some rows of the_table>
SELECT MAX (t.a_date)
, MAX (t.ID)KEEP (DENSE_RANK LAST ORDER BY t.a_date ASC)
FROM the_table t
WHERE <condition to get only some rows of the_table>2) can I use als the min function for t.ID as there the aggregate function does not have any effect (but is necessary in order to use KEEP and FIRST or KEEP and LAST)?
With regards,
Cosima
Message was edited by:
Cosima Laube -
Join tables with aggregate function
Hello
I have 4 views that I need to perform aggregate function, count, on and then join them for query output.
Basically each view has a column with a score and a subcontractor name. One subcontractor may have more than one score in each view.
Here is the sql that I'm working with thus far:
select e.sub_name, (count(e.score) - 1), (count(v.score) - 1), (count(s.score) - 1), (count(u.score) - 1)
from speed.v_ratings_ex e, speed.v_ratings_vg v, speed.v_ratings_sat s, speed.v_ratings_uns u
where v.sub_name = e.sub_name
and s.sub_name = e.sub_name
and u.sub_name = e.sub_name
group by e.sub_name
order by e.sub_name asc;
This results in each column returning the same value b/c the join is performed before the aggregate function.
Can anyone offer some help so that I may get the desired results?You need to use in-line views to perform the aggregates, then join the in-line views.
Something like:
SELECT e.sub_name, e.score - 1 escore, v.score - 1 vscore,
s.score - 1 sscore, u.score - 1 uscore
FROM (SELECT sub_name,count(*) score
FROM v_ratings_ex
GROUP BY sub_name) e,
(SELECT sub_name,count(*) score
FROM v_ratings_vg
GROUP BY sub_name) v,
(SELECT sub_name,count(*) score
FROM v_ratings_sat
GROUP BY sub_name) s,
(SELECT sub_name,count(*) score
FROM v_ratings_uns
GROUP BY sub_name) u
WHERE v.sub_name = e.sub_name and
s.sub_name = e.sub_name and
u.sub_name = e.sub_name
ORDER BY e.sub_name asc;TTFn
John -
Hi!
I have a problem with List View Report in mobile application (theme 50 in apex) after updating to apex 4.2.2. I created Report -> List View. I used select from pipelined function in Region Source. Then when page is running and submited three times (or refreshed three times) I get an error:
Error during rendering of region "LIST VIEW".
ORA-01007: variable not in select list
Technical Info (only visible for developers)
is_internal_error: true
apex_error_code: APEX.REGION.UNHANDLED_ERROR
ora_sqlcode: -1007
ora_sqlerrm: ORA-01007: variable not in select list
component.type: APEX_APPLICATION_PAGE_REGIONS
component.id: 21230833903737364557
component.name: LIST VIEW
error_backtrace:
ORA-06512: at "APEX_040200.WWV_FLOW_DISP_PAGE_PLUGS", line 4613
ORA-06512: at "APEX_040200.WWV_FLOW_DISP_PAGE_PLUGS", line 3220
I get this error only when I use select from pipelined function in Region Source (for example: "select value1, value2 from table(some_pipelined_function(param1, param2)) ").
You can check it on http://apex.oracle.com/pls/apex/f?p=50591 (login - demo, password - demo).
In this application:
- I created package TAB_TYPES_PKG:
create or replace PACKAGE TAB_TYPES_PKG IS
TYPE cur_rest_r IS RECORD (
STR_NAME VARCHAR2(128),
INFO VARCHAR2(128)
TYPE cur_rest_t IS TABLE OF cur_rest_r;
END TAB_TYPES_PKG;
- I created pipelined function TEST_FUNC:
create or replace
FUNCTION TEST_FUNC
RETURN TAB_TYPES_PKG.cur_rest_t PIPELINED IS
r_cur_rest TAB_TYPES_PKG.cur_rest_r;
BEGIN
r_cur_rest.STR_NAME := 'ROW 1';
r_cur_rest.INFO := '10';
PIPE ROW (r_cur_rest);
r_cur_rest.STR_NAME := 'ROW 2';
r_cur_rest.INFO := '20';
PIPE ROW (r_cur_rest);
r_cur_rest.STR_NAME := 'ROW 3';
r_cur_rest.INFO := '30';
PIPE ROW (r_cur_rest);
r_cur_rest.STR_NAME := 'ROW 4';
r_cur_rest.INFO := '40';
PIPE ROW (r_cur_rest);
r_cur_rest.STR_NAME := 'ROW 5';
r_cur_rest.INFO := '50';
PIPE ROW (r_cur_rest);
RETURN;
END TEST_FUNC;
- I created List View Report on Page 1:
Region Source:
SELECT str_name,
info
FROM TABLE (TEST_FUNC)
We can see error ORA-01007 after refresing (or submiting) Page 1 three times or more.
How to fix it?Hi all
I'm experiencing the same issue. Predictably on every third refresh I receive:
Error
Error during rendering of region "Results".
ORA-01007: variable not in select list
Technical Info (only visible for developers)
is_internal_error: true
apex_error_code: APEX.REGION.UNHANDLED_ERROR
ora_sqlcode: -1007
ora_sqlerrm: ORA-01007: variable not in select list
component.type: APEX_APPLICATION_PAGE_REGIONS
component.id: 6910805644140264
component.name: Results
error_backtrace: ORA-06512: at "APEX_040200.WWV_FLOW_DISP_PAGE_PLUGS", line 4613 ORA-06512: at "APEX_040200.WWV_FLOW_DISP_PAGE_PLUGS", line 3220
OK
I am running Application Express 4.2.2.00.11 on GlassFish 4 using Apex Listener 2.0.3.221.10.13.
Please note: this works perfectly using a classic report in my desktop application; however, no joy on the mobile side with a list view. I will use a classic report in the interim.
My region source is as follows:
SELECT description AS "DESCRIPTION", reference AS "REFERENCE" FROM TABLE(AUTOCOMPLETE_LIST_VIEW_FNC('RESULTS'))
The procedure:
FUNCTION AUTOCOMPLETE_LIST_VIEW_FNC(
p_collection_name IN VARCHAR2)
RETURN list_row_table_type
AS
v_tab list_row_table_type := list_row_table_type();
BEGIN
DECLARE
jsonarray json_list;
jsonobj json;
json_clob CLOB;
BEGIN
SELECT clob001
INTO json_clob
FROM apex_collections
WHERE collection_name = p_collection_name;
jsonobj := json(json_clob);
jsonarray := json_ext.get_json_list(jsonobj, 'predictions');
FOR i IN 1..jsonArray.count
LOOP
jsonobj := json(jsonArray.get(i));
v_tab.extend;
v_tab(v_tab.LAST) := list_row_type(json_ext.get_string(jsonobj, 'description'), json_ext.get_string(jsonobj, 'reference'));
END LOOP;
RETURN(v_tab);
END;
END AUTOCOMPLETE_LIST_VIEW_FNC;
Thanks!
Tim -
Update of a table from a select query with aggregate functions.
Hello All,
I have problem here:
I have 2 tables A(a1, a2, a3, a4, a4....... ) and B( a1, a2, b1, b2, b3). I need to calculate the avg(a4-a3), Max(a4-a3) and Min(a4-a3) and insert it into table B. If the foreign keys a1, a2 already exist in table B, I need to do an update of the computed values into column b1, b2 and b3 respectively, for a1, a2.
Q1. Is it possible to do this with a single query ? I would prefer not to join A with B because the table A is very large. Also columns b1, b2 and b3 are non-nullable.
Q2. Also if a4 and a3 are timestamps what is the best way to find the average? A difference of timestamps yields INTERVAL DAY TO SECOND over which the avg function doesn't seem to work. The averages, max and min in my case would be less than a day and hence all I need is to get the data in the hh:mm:ss format.
As of now I'm using :
TO_CHAR(TO_DATE(ABS(MOD(TRUNC(AVG(extract(hour FROM (last_modified_date - created_date))*3600 +
extract( minute FROM (last_modified_date - created_date))*60 +
extract( second FROM (last_modified_date - created_date)))
),86400)),'sssss'),'hh24":"mi":"ss') AS avg_time,
But this is very long drawn. Something more compact and efficient would be nice.
Thanks in advance for your inputs.
Edited by: 847764 on Mar 27, 2011 5:35 PM847764 wrote:
Hi,
Thanks everyone for such fast replies. Malakshinov's example worked fine for me as far as updating the table goes. As for the timestamp computations, I'm posting additional info: Sorry, I don't understand.
If Malakshinov's example worked for updating the table, but you still have problems, does that mean you have to do something else besides update the table? If so, what?
Oracle version : Oracle Database 11g Enterprise Edition Release 11.2.0.1.0
Here are the table details :
DESC Table A
Name Null Type
ID NOT NULL NUMBER
A1 NOT NULL VARCHAR2(4)
A2 NOT NULL VARCHAR2(40)
A3 NOT NULL VARCHAR2(40)
CREATED_DATE NOT NULL TIMESTAMP(6)
LAST_MODIFIED_DATE TIMESTAMP(6) DESCribing the tables can help clarify some things, but it's no substitute for posting CREATE TABLE and INSERT statements. With only a description of the table, nobody can re-create the problem or test their ideas. Please post CREATE TABLE and INSERT statements for both tables as they exist before the MERGE. If table b doen't contain any rows before the MERGE, then just say so, but you still need to post a CREATE TABLE statement for both tables, and INSERT statements for table a.
The objective is to compute the response times : avg (LAST_MODIFIED_DATE - CREATED_DATE), max (LAST_MODIFIED_DATE - CREATED_DATE) and min (LAST_MODIFIED_DATE - CREATED_DATE) grouped by A1 and A2 and store it in table B under AVG_T, MAX_T and MIN_T. Since AVG_T, MAX_T and MIN_T are only used for reporting purposes we have kept it as Varchar (though I think keeping it as timestamp would make more sense). I think a NUMBER would make more sense (the number of minutes, for example), or perhaps an INTERVAL DAY TO SECOND. If you stored a NUMBER, it would be easy to compute averages.
In table B the times are stored in the format : hh:mm:ss. We don't need milliseconds precision. If you don;'t need milliseconds, then you should use DATE instead of TIMESTAMP. The functions for manipulating DATEs are much better.
Hence I was calculating is as follows:
-- Avg Time
TO_CHAR(TO_DATE(ABS(MOD(TRUNC(AVG(extract(hour FROM (last_modified_date - created_date))*3600 +
extract( minute FROM (last_modified_date - created_date))*60 +
extract( second FROM (last_modified_date - created_date)))
),86400)),'sssss'),'hh24":"mi":"ss') AS avg_time,
--Max Time
extract (hour FROM MAX(last_modified_date - created_date))||':'||extract (minute FROM MAX(last_modified_date - created_date))||':'||TRUNC(extract (second FROM MAX(last_modified_date - created_date))) AS max_time,
--Min Time
extract (hour FROM MIN(last_modified_date - created_date))||':'||extract (minute FROM MIN(last_modified_date - created_date))||':'||TRUNC(extract (second FROM MIN(last_modified_date - created_date))) AS min_timeIs this something that has to be done before or after the MERGE?
Post the complete statement.
Is this part of a query? Where's the SELECT keyword?
Is this part of a DML operation? Where's the INSERT, or UPDATE, or MERGE keyword?
What are the exact results you want from this? Explain how you get those results.
Is the code above getting the right results? Are you just asking if there's a better way to get the same results?
You have to explain things very carefully. None of the people who want to help you are familiar with your application, or your needs.
I just noticed that my reply is horribly formatted - apologies! I'm just getting the hang of it.Whenever you post formatted text (such as query results) on this site, type these 6 characters:
\(small letters only, inside curly brackets) before and after each section of formatted text, to preserve spacing. -
How to use analytic function with aggregate function
hello
can we use analytic function and aggrgate function in same qurey? i tried to find any example on Net but not get any example how both of these function works together. Any link or example plz share with me
Edited by: Oracle Studnet on Nov 15, 2009 10:29 PMselect
t1.region_name,
t2.division_name,
t3.month,
t3.amount mthly_sales,
max(t3.amount) over (partition by t1.region_name, t2.division_name)
max_mthly_sales
from
region t1,
division t2,
sales t3
where
t1.region_id=t3.region_id
and
t2.division_id=t3.division_id
and
t3.year=2004
Source:http://www.orafusion.com/art_anlytc.htm
Here max (aggregate) and over partition by (analytic) function is in same query. So it means we can use aggregate and analytic function in same query and more than one analytic function in same query also.
Hth
Girish Sharma -
Download report with Aggregates
Hi I am using
Application Express 4.0.2.00.07
I have been trying to figure out a way to print the aggregate that is in my IR to be printed/downloaded into CSV or HTML.
I have no problem in printing the report but I cant get the aggregate(sum) to be printed any ideas?
ThanksAny ideas? Any one?
-
Timestamp coming in report with evaluate function
Hi All,
I have one date prompt where i have defined the presentation variable pvar_strt_dt.
Now i am running report which captures the value of pvar_strt_dt
but i m getting following error as follows
State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 17001] Oracle Error code: 1843, message: ORA-01843: not a valid month at OCI call OCIStmtFetch. [nQSError: 17012] Bulk fetch failed. (HY000)
SQL Issued: SELECT EVALUATE('TO_DATE(%1,%2)', '2011-02-21 00:00:00','mm/dd/yyyy hh:mi:ss') saw_0, Time.Date saw_1
I m using this in my formula of the report.....EVALUATE('TO_DATE(%1,%2)', '@{pvar_strt_dt}','mm/dd/yyyy hh:mi:ss')
Any help in this regard.EVALUATE('TO_DATE(%1,%2)', '@{pvar_strt_dt}','mm/dd/yyyy hh:mi:ss')When you use to to_date function it defaults to dd/mm/yy not what you have specified,Insead use to_char if you want to specify the format you wish too.Check even the syntax
hope helps you.
Cheers,
KK -
Update statement with Aggregate function
Hi All,
I would like to update the records with sum of SAL+COMM+DEPTNO into SALCOMDEPT column for each row. Can we use SUM function in Update statement. Please help me out this
See below:
Table
CREATE TABLE EMP
EMPNO NUMBER(4) NOT NULL,
ENAME VARCHAR2(10 CHAR),
JOB VARCHAR2(9 CHAR),
MGR NUMBER(4),
HIREDATE DATE,
SAL NUMBER(7,2),
COMM NUMBER(7,2),
DEPTNO NUMBER(2),
SALCOMDEPT NUMBER
Used update statement :
UPDATE emp e1
SET e1.salcomdept= (select sum(sumsal+comm+deptno) from emp e2 where e2.empno=e1.empno)
WHERE e1.deptno = 10
commit
Thanks,
UserAdding these columns makes no sense, so I'll assume this is just an exercise.
However, storing calculated columns like this is generally not a good idea. If one of the other columns is updated, your calculated column will be out of sync.
One way around this is to create a simple view
SQL> CREATE view EMP_v as
2 select EMPNO
3 ,ENAME
4 ,JOB
5 ,MGR
6 ,HIREDATE
7 ,SAL
8 ,COMM
9 ,DEPTNO
10 ,(nvl(sal,0) + nvl(comm,0) + nvl(deptno,0)) SALCOMDEPT
11 from emp;
View created.
SQL> select sal, comm, deptno, salcomdept from emp_v;
SAL COMM DEPTNO SALCOMDEPT
800 20 820
1600 300 30 1930
1250 500 30 1780
2975 20 2995
1250 1400 30 2680
2850 30 2880
2450 10 2460
3000 20 3020
5000 10 5010
1500 0 30 1530
1100 20 1120
950 30 980
3000 20 3020
1300 10 1310
14 rows selected. -
The code field on my user table is too small for the key field I want to use but it is still necessary I assume I must generate my own unique value.
The DBDataSource.Query() method doesn't seem appropriate so should I create a SAPbobsCOM.Recordset and use the DoQuery method to select the maximum value currently in the user table?
I found some mentions of requiring such a select statement on this board but no examples of the actual code. I'll go ahead and try the DoQuery method unless I hear of something more appropriate.
Also, I saw a comment that a future release of SAP would have a larger code field for user tables but obviously that didn't happen in 6.7.
Thanks for any comments.
Bill FaulkHere's what I came up with...
If you are happy with 99,999,999 records instead of 4,294,967,295 then I guess you can forego the hexadecimal bit. I'd welcome any alternatives if someone has one.
With the hex:
private string GetNextKey(string strTable)
SAPbobsCOM.Recordset rs =
(SAPbobsCOM.Recordset)oCompany.GetBusinessObject(BoObjectTypes.BoRecordset);
rs.DoQuery("select isnull(max(code),'00000000') from [" + strTable + "]");
string strCode = (string)rs.Fields.Item(0).Value;
int intKey = Convert.ToInt32(strCode,16) + 1;
return intKey.ToString("X8");
No Hex:
private string GetNextKey(string strTable)
SAPbobsCOM.Recordset rs =
(SAPbobsCOM.Recordset)oCompany.GetBusinessObject(BoObjectTypes.BoRecordset);
rs.DoQuery("select isnull(max(code),'00000000') from [" + strTable + "]");
string strCode = (string)rs.Fields.Item(0).Value;
int intKey = Convert.ToInt32(strCode) + 1;
return intKey.ToString("00000000"); -
Select with aggregate function MAX
Hi,
Can I write a query like:
select field1 field2 MAX( field3 )
from z_table
into table itab
for all entries in itab2
where field1 = itab2-field1
and field2 = itab2-field2.
In the above case all the 3 fields are key fields.
Thanks in advance.Hi,
I did try it.. but got an error like: "The field "z_table~field2" from the select list is missing in the GROUP BY clause" but my aggregate funtion is used only for the field3..... So, I wanted to know if anybody has come across such a query....
Thanks, -
Help with aggregate function max query
I have a large database which stores daily oil life, odo readings from thousands of vehicles being tested but only once a month.
I am trying to grab data from one month where only the EOL_READ = 0 and put all of those values into the previous month's query where EOL_READ = anything.
Here is the original query which grabs everything
(select distinct vdh.STID, vdh.CASE_SAK,
max(to_number(decode(COMMAND_ID,'EOL_READ',COMMAND_RESULT,-100000))) EOL_READ,
max(to_number(decode(COMMAND_ID,'ODO_READ',COMMAND_RESULT,-100000))) ODO_READ,
max(to_number(decode(COMMAND_ID,'OIL_LIFE_PREDICTION',COMMAND_RESULT,-100000))) OIL_LIFE_PREDICTION
from veh_diag_history vdh, c2pt_data_history cdh
where vdh.veh_diag_history_sak = cdh.veh_diag_history_sak
and cdh.COMMAND_ID in ('EOL_READ','ODO_READ','OIL_LIFE_PREDICTION')
and vdh.LOGICAL_TRIGGER_SAK = 3
and cdh.CREATED_TIMESTAMP =vdh.CREATED_TIMESTAMP
and cdh.CREATED_TIMESTAMP >= to_date('03/01/2007 12:00:00 AM','mm/dd/yyyy HH:MI:SS AM')
and cdh.CREATED_TIMESTAMP < to_date('04/01/2007 12:00:00 AM','mm/dd/yyyy HH:MI:SS AM')
group by vdh.STID, vdh.case_sak
having count(distinct command_id) = 3
order by OIL_LIFE_PREDICTION)
which gives 5 columns:
STID, CASE_SAK, EOL_READ, ODO_READ, and OIL_LIFE_PREDICTION
and gives me about 80000 rows returned for the above query
I only want one reading per month, but sometimes I get two.
STID is the unique identifier for a vehicle.
I tried this query:
I tried this query which nests one request within the other and SQL times out every time:
select distinct vdh.STID, vdh.CASE_SAK,
max(to_number(decode(COMMAND_ID,'EOL_READ',COMMAND_RESULT,-100000))) EOL_READ,
max(to_number(decode(COMMAND_ID,'ODO_READ',COMMAND_RESULT,-100000))) ODO_READ,
max(to_number(decode(COMMAND_ID,'OIL_LIFE_PREDICTION',COMMAND_RESULT,-100000))) OIL_LIFE_PREDICTION
from veh_diag_history vdh, c2pt_data_history cdh
where vdh.veh_diag_history_sak = cdh.veh_diag_history_sak
and cdh.COMMAND_ID in ('EOL_READ','ODO_READ','OIL_LIFE_PREDICTION')
and vdh.LOGICAL_TRIGGER_SAK = 3
and cdh.CREATED_TIMESTAMP =vdh.CREATED_TIMESTAMP
and cdh.CREATED_TIMESTAMP >= to_date('02/01/2007 12:00:00 AM','mm/dd/yyyy HH:MI:SS AM')
and cdh.CREATED_TIMESTAMP < to_date('03/01/2007 12:00:00 AM','mm/dd/yyyy HH:MI:SS AM')
group by vdh.STID, vdh.case_sak
having count(distinct command_id) = 3
and vdh.stid in (select distinct vdh.STID, vdh.CASE_SAK,
max(to_number(decode(COMMAND_ID,'EOL_READ',COMMAND_RESULT,-100000))) EOL_READ,
max(to_number(decode(COMMAND_ID,'ODO_READ',COMMAND_RESULT,-100000))) ODO_READ,
max(to_number(decode(COMMAND_ID,'OIL_LIFE_PREDICTION',COMMAND_RESULT,-100000))) OIL_LIFE_PREDICTION
from veh_diag_history vdh, c2pt_data_history cdh
where vdh.veh_diag_history_sak = cdh.veh_diag_history_sak
and cdh.COMMAND_ID in ('EOL_READ','ODO_READ','OIL_LIFE_PREDICTION')
and vdh.LOGICAL_TRIGGER_SAK = 3
and cdh.CREATED_TIMESTAMP =vdh.CREATED_TIMESTAMP
and cdh.CREATED_TIMESTAMP >= to_date('03/01/2007 12:00:00 AM','mm/dd/yyyy HH:MI:SS AM')
and cdh.CREATED_TIMESTAMP < to_date('04/01/2007 12:00:00 AM','mm/dd/yyyy HH:MI:SS AM')
group by vdh.STID, vdh.case_sak
having count(distinct command_id) = 3
and (max(to_number(decode(COMMAND_ID,'EOL_READ',COMMAND_RESULT,-100000)))) = 0)
order by OIL_LIFE_PREDICTION
so in summary I am trying to select values from the previous month only from those stids where this month's value for EOL_READ = 0
Any ideas.....please help.You can use row_number() within each stid and each month to determine the first read of each month. Then you can use lag() to get the previous month's reading of the current month's reading is zero.
with all_data as (
select stid,
case_sak,
eol_read,
timestamp,
row_number() over (partition by stid, trunc(timestamp,'mm') order by timestamp) AS rn
from veh_diag_history
select stid,
case_sak,
case
when eol_read = 0
then lag(eol_read) over (partition by stid order by timestamp)
else eol_read
end as eol_read
from all_data
where rn = 1; -
Reports with all functionality (sorting,total,subtotal,download)
Hi,
We require that all the actions which we can perform on the Reports available in SAP environment should also be available in the EP Platform.
Eg
sorting,total,subtotal,download.
Thanks.Hi,
We require that all the actions which we can perform on the Reports available in SAP environment should also be available in the EP Platform.
Eg
sorting,total,subtotal,download.
Thanks. -
Need complex query with joins and AGGREGATE functions.
Hello Everyone ;
Good Morning to all ;
I have 3 tables with 2 lakhs record. I need to check query performance.. How CBO rewrites my query in materialized view ?
I want to make complex join with AGGREGATE FUNCTION.
my table details
SQL> select from tab;*
TNAME TABTYPE CLUSTERID
DEPT TABLE
PAYROLL TABLE
EMP TABLE
SQL> desc emp
Name
EID
ENAME
EDOB
EGENDER
EQUAL
EGRADUATION
EDESIGNATION
ELEVEL
EDOMAIN_ID
EMOB_NO
SQL> desc dept
Name
EID
DNAME
DMANAGER
DCONTACT_NO
DPROJ_NAME
SQL> desc payroll
Name
EID
PF_NO
SAL_ACC_NO
SALARY
BONUS
I want to make complex query with joins and AGGREGATE functions.
Dept names are : IT , ITES , Accounts , Mgmt , Hr
GRADUATIONS are : Engineering , Arts , Accounts , business_applications
I want to select records who are working in IT and ITES and graduation should be "Engineering"
salary > 20000 and < = 22800 and bonus > 1000 and <= 1999 with count for males and females Separately ;
Please help me to make a such complex query with joins ..
Thanks in advance ..
Edited by: 969352 on May 25, 2013 11:34 AM969352 wrote:
why do you avoid providing requested & NEEDED details?I do NOT understand what do you expect ?
My Goal is :
1. When executing my own query i need to check expalin plan.please proceed to do so
http://docs.oracle.com/cd/E11882_01/server.112/e26088/statements_9010.htm#SQLRF01601
2. IF i enable query rewrite option .. i want to check explain plan ( how optimizer rewrites my query ) ? please proceed to do so
http://docs.oracle.com/cd/E11882_01/server.112/e16638/ex_plan.htm#PFGRF009
3. My only aim is QUERY PERFORMANCE with QUERY REWRITE clause in materialized view.It is an admirable goal.
Best Wishes on your quest for performance improvements. -
SSRS - Interactive sorting based on aggregate function
Hi,
I'm trying to add interactive sorting to one of the columns in my tablix.
The soring should be based on the LAST visit date of my child grouping. However interactive sorting is not compatible with aggregate functions apparently.
I'm using the following expression to sort on the period since the last visit:
=DateDiff(
"d"
,LAST(CDate(Fields!Visit_date.Value))
,Today()
Anyone an idea how to get this done?
Regards,
LiskieWhiskyThanks for the input,
Qiuyun Yu: I already applied your method but my issues is that the visit dates are on de level of my
child grouping and per child multiple visit dates are possible. Since I want to complute the days since the last visit I need to take the last visit date and subtract it from today's date.
As you can see there are 2 dates. To compute the days since the last visit I take the last visit date (2015-04-17)
and subtract it from today (2015-04-27). This gives me 10 days. That's ok, no problem there.
But because I'm using the Last() function, I cannot use this expression in the Interactive sorting expression.
LucasF: You are right, but if it's possible to do this in the report I'd prefer that. But ultimately if it's necessary I'll have to do it in MDX then.
Kind regards,
LiskieWhisky
Maybe you are looking for
-
Console events while lid closed
Hi Recently I noticed on my MacBook Air console (late 2012, running Yosemite) some events during a very short period of 3 hours when the lid was closed and I was not using it. I was actually out, but when I came back just out of interest noticed seve
-
Delete row from internal table using field symbol.
Hi friends, I created dynamic internal table using field symbol. I want to delete some data using where clause. for example. i want to use like, DELETE <FS> WHERE KUNNR = WA_KNA1-KUNNR. Like the above statment it won't work. How i can use delet
-
Flow of order reasons from crm to r/3
Hi All I just want to know whether orders can be flowed from CRM to R/3. In my scenario i am creating a return order in CRM with order reasons and will be replicating the same to R/3. Do order reasons also replicate to R/3 in this case. If so what a
-
Cant play mensa games on iPad?
Is anyone having problems trying to play games on the us.mensa.org site? I can play them on my desktop and laptop but NOT on my ipad! I tried using google chrome and also updating the software but it still isnt working. I just get a blank screen and
-
App not install after 3 days HELP
I bought an app called Day One on the 15th of July, it still did not install after 3 days. Everytime I try to install it, this message comes up 'Day One failed to download use the purchases page to try again.' This is what shows up on the launchpad.