Adding columns in the group by clause
HelloMy query is like this,
Select empid, sum (sal) in the group by empid emp,
I want additional columns to be included in the request
Select empid, address, sum (sal) in the group by empid
Is there a possible way to include the other columns outside the group by column.
Thank you
Hi, you can write like this
select a.empid,e.address,a.sal from(
select empid , sum(sal)as sal from emp group by empid )a ,emp e
where a.empid=e.empid
Published by: user10736825 on January 25, 2010 12:59
Tags: Database
Similar Questions
-
Select the columns not in the group by clause
Hello
My version of DB is 10.0.2
I have query, where in I need to select two columns more but that should not be part of the group by Clause.
Does perform a work around?
SELECT F.custnum, V.Import_date, -- F.ErledigtMM,F.ErledigtGrundMM, (Columns to be selected additionally) nvl(sum(nvl(round(V.VerAuf16/1000,2), 0) +nvl(round(V.VerAuf17/1000,2), 0) + nvl(round(V.VerAuf18/1000,2), 0) + nvl(round(V.VerAuf19/1000,2), 0) + nvl(round(V.VerAuf20/1000,2), 0) + nvl(round(V.VerAufKAPUn/1000,2), 0) + nvl(round(V.VerAufKAPVz/1000,2), 0) ), 0) Mandantenforderung, nvl(sum(nvl(round(V.VerAuf4/1000,2), 0) ), 0) Inkassokosten, nvl(sum(nvl(round(V.VerAuf5/1000,2), 0) ), 0) KontoFuehrungsgebuehren, nvl(sum(nvl(round(V.VerAuf1/1000,2), 0) + nvl(round(V.VerAuf2/1000,2), 0) ), 0) Verwertungskosten, nvl(sum(nvl(round(V.VerAuf10/1000,2), 0) + nvl(round(V.VerAuf8/1000,2), 0) + nvl(round(V.VerAuf9/1000,2), 0) ), 0) Barauslagen, nvl(sum(nvl(round(V.VerAuf13/1000,2), 0) + nvl(round(V.VerAuf14/1000,2), 0) + nvl(round(V.VerAuf15/1000,2), 0) + nvl(round(V.VerAuf6/1000,2), 0) ),0) Gerichtskosten, nvl(sum(nvl(round(V.VerAuf11/1000,2), 0) + nvl(round(V.VerAuf12/1000,2), 0) + nvl(round(V.VerAuf7/1000,2), 0) ), 0) RAKosten, TO_CHAR(F.Created_Date,'MM.YYYY') Created_Date_MM , TO_CHAR(F.Created_Date,'YYYY') Created_Date_MMRRRR FROM FACM F, VA V WHERE F.custnum = DECODE(0,0,F.custnum,0) AND F.accnum = V.accnum GROUP BY F.custnum, V.Import_date,TO_CHAR(F.Created_Date,'MM.YYYY') ,TO_CHAR(F.Created_Date,'YYYY'))
Hello
Here's what I suggest:
select a.custnum, a.import_date, b.ErledigtMM, b.ErledigtGrundMM, a.Mandantenforderung, a.Inkassokosten, a.KontoFuehrungsgebuehren, a.Verwertungskosten, a.Barauslagen, a.Gerichtskosten, a.RAKosten, a.Created_Date_MM , a.Created_Date_MMRRRR from ( SELECT F.custnum, V.Import_date, nvl(sum(nvl(round(V.VerAuf16/1000,2), 0) +nvl(round(V.VerAuf17/1000,2), 0) + nvl(round(V.VerAuf18/1000,2), 0) + nvl(round(V.VerAuf19/1000,2), 0) + nvl(round(V.VerAuf20/1000,2), 0) + nvl(round(V.VerAufKAPUn/1000,2), 0) + nvl(round(V.VerAufKAPVz/1000,2), 0) ), 0) Mandantenforderung, nvl(sum(nvl(round(V.VerAuf4/1000,2), 0) ), 0) Inkassokosten, nvl(sum(nvl(round(V.VerAuf5/1000,2), 0) ), 0) KontoFuehrungsgebuehren, nvl(sum(nvl(round(V.VerAuf1/1000,2), 0) + nvl(round(V.VerAuf2/1000,2), 0) ), 0) Verwertungskosten, nvl(sum(nvl(round(V.VerAuf10/1000,2), 0) + nvl(round(V.VerAuf8/1000,2), 0) + nvl(round(V.VerAuf9/1000,2), 0) ), 0) Barauslagen, nvl(sum(nvl(round(V.VerAuf13/1000,2), 0) + nvl(round(V.VerAuf14/1000,2), 0) + nvl(round(V.VerAuf15/1000,2), 0) + nvl(round(V.VerAuf6/1000,2), 0) ),0) Gerichtskosten, nvl(sum(nvl(round(V.VerAuf11/1000,2), 0) + nvl(round(V.VerAuf12/1000,2), 0) + nvl(round(V.VerAuf7/1000,2), 0) ), 0) RAKosten, TO_CHAR(F.Created_Date,'MM.YYYY') Created_Date_MM , TO_CHAR(F.Created_Date,'YYYY') Created_Date_MMRRRR FROM FACM F, VA V WHERE F.custnum = DECODE(0,0,F.custnum,0) AND F.accnum = V.accnum GROUP BY F.custnum, V.Import_date,TO_CHAR(F.Created_Date,'MM.YYYY') ,TO_CHAR(F.Created_Date,'YYYY')) ) a, FACM b where b.custnum = a.custnum
By the way
WHERE F.custnum = DECODE(0,0,F.custnum,0) AND F.accnum = V.accnum
can be translated into
WHERE F.accnum = V.accnum
because
F.custnum = DECODE(0,0,F.custnum,0)
is always true
becauseDECODE(0,0,F.custnum,0)
means
if 0=0 then F.custnum else 0
-
Concatenation of data with the GROUP BY clause
Hi again!
Following my previous thread...
I tried to apply the GROUP BY clause instead of preforming my query with RANK() to manage records NULL... I have a scenario where I also need to concatenate data from several lines.
CREATE TABLE T_EMP (NUMBER OF EMP_NO, NAME VARCHAR2 (20));
INSERT INTO T_EMP VALUES (1001, 'MARK');
INSERT INTO T_EMP VALUES (1002, 'DAVID');
INSERT INTO T_EMP VALUES (1003, "SHAUN");
INSERT INTO T_EMP VALUES (1004, "JILL");
CREATE TABLE T_EMP_DEPT (NUMBER OF EMP_NO, DEPT_NO NUMBER);
INSERT INTO T_EMP_DEPT VALUES (1001, 10);
INSERT INTO T_EMP_DEPT VALUES (1001, 20);
INSERT INTO T_EMP_DEPT VALUES (1002, 10);
INSERT INTO T_EMP_DEPT VALUES (1002, 20);
INSERT INTO T_EMP_DEPT VALUES (1002, 30);
INSERT INTO T_EMP_DEPT VALUES (1003, 20);
INSERT INTO T_EMP_DEPT VALUES (1003, 30);
INSERT INTO T_EMP_DEPT VALUES (1004, 10);
CREATE TABLE T_EMP_VISITS (NUMBER OF EMP_NO, DEPT_NO NUMBER, VISITED DATE);
INSERT INTO T_EMP_VISITS VALUES (1001, 10, 1 JAN 2009');
INSERT INTO T_EMP_VISITS VALUES (1002, 10, 1 JAN 2009');
INSERT INTO T_EMP_VISITS VALUES (1002, 30, 11 APR 2009');
INSERT INTO T_EMP_VISITS VALUES (1003, 20, 3 MAY 2009');
INSERT INTO T_EMP_VISITS VALUES (1003, 30: 14 FEB 2009');
COMMIT;
I have a T_EMP master table that stores the name and number of the emp. Each emp is required to visit some departments. This mapping is stored in the T_EMP_DEPT table. An employee can visit one or more departments. T_EMP_VISITS table stores the dates where the employee visited the services required. I need to view the report which should show when an employee all completed visits, which is the maximum date when it finished to visit all departments. If he did not visit any of the report should display date max, otherwise NULL. I was able to do using GROUP BY such proposed by Salim, but how do I show a list separated by commas of the services required for an employee in the same query.
SELECT
EMP_NO,
NAME,
MAX (DEPT_NO) KEEP (DENSE_RANK LAST ORDER BY VISITED) MAX_DEPT_NO,.
MAX (VISITED) KEEP (DENSE_RANK LAST ORDER PER VISIT) VISITS_COMP
DE)
SELECT
T_EMP. EMP_NO,
NAME,
T_EMP_DEPT. DEPT_NO,
VISITED
OF T_EMP
LEFT OUTER JOIN T_EMP_DEPT
ON T_EMP. EMP_NO = T_EMP_DEPT. EMP_NO
LEFT OUTER JOIN T_EMP_VISITS
ON T_EMP_DEPT. EMP_NO = T_EMP_VISITS. EMP_NO
AND T_EMP_DEPT. DEPT_NO = T_EMP_VISITS. DEPT_NO)
GROUP EMP_NO, NAME;
Output
EMP_NO NAME MAX_DEPT_NO VISITS_COMP
1001 MARK 20
1002 DAVID 20
1003 SHAUN 20 3 MAY 09
JILL 1004
Power required
EMP_NO NAME REQ_DEPTS MAX_DEPT_NO VISITS_COMP
1001 MARC 20 10.20
1002 DAVID 10,20,30 20
1003 SHAUN 20,30 20 3 MAY 09
JILL 10 1004
Can we do this in a single query?Hello
user512647 wrote:
... Sanjay
The query you provided that stragg() use seems to work but my requirement is not in the result set. I don't know how to use stragg with
MAX (DEPT_NO) KEEP (DENSE_RANK LAST ORDER BY VISITED) MAX_DEPT_NO,.
MAX (VISITED) KEEP (DENSE_RANK LAST ORDER PER VISIT) VISITS_COMP
I need more, these two columns these gives me the date when they have completed all visits. If they missed any Department then the result must be NULL in the VISITS_COMP field.Just add them to the SELECT clause:
SELECT t_emp.emp_no, name, STRAGG (t_emp_dept.dept_no) AS deptno, MAX (t_emp_dept.dept_no) KEEP (DENSE_RANK LAST ORDER BY visited) AS max_dept_no, MAX (visited) AS visits_comp FROM t_emp LEFT OUTER JOIN t_emp_dept ON t_emp.emp_no = t_emp_dept.emp_no LEFT OUTER JOIN t_emp_visits ON t_emp_dept.emp_no = t_emp_visits.emp_no AND t_emp_dept.dept_no = t_emp_visits.dept_no GROUP BY t_emp.emp_no , name ;
The column called visit_comp is simply the last visited, regardless of how the employee visited departments.
If you want to have the NULL value if the employee has not yet visited all 3 departments:... CASE WHEN COUNT (DISTINCT t_emp_dept.dept_no) = 3 THEN MAX (visited) END AS visits_comp
The 'magic number' 3 is the total number of departments.
If you want to understand the correct value of that at the time of the execution of the query, replace the code literal 3 hard with a scalar subquery.Note that 'KEEP MAX (x) (DENSE_RANK OVER LAST SERVICE BY x)' (where the exact same column is used as an argument and that the ORDER BY column) is just "MAX (x)".
-
What's the point of having several columns in the ORDER BY clause?
DB version: 10 gr 2
When you use the ORDER BY clause, the lines are always sorted by the first column in the ORDER BY clause. So, what's the point of having several columns in the ORDER BY clause (I always see this in production codes)?
For the below SQLs' schema SCOTT, result sets are always classified according to the first column ename. When I added use asc and desc of employment, does not change the result set.
SQL> select * from emp order by ename; EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO ---------- ---------- --------- ---------- --------- ---------- ---------- ---------- 7876 ADAMS CLERK 7788 23-MAY-87 1100 20 7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30 7698 BLAKE MANAGER 7839 01-MAY-81 2850 30 7782 CLARK MANAGER 7839 09-JUN-81 2450 20 7902 FORD ANALYST 7566 03-DEC-81 3000 20 7900 JAMES CLERK 7698 03-DEC-81 950 30 7566 JONES MANAGER 7839 02-APR-81 2975 20 7839 KING PRESIDENT 17-NOV-81 5000 20 7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30 7934 MILLER CLERK 7782 23-JAN-82 1300 20 7788 SCOTT ANALYST 7566 19-APR-87 3000 20 7369 SMITH CLERK 7902 17-DEC-80 800 20 7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30 7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30 14 rows selected. SQL> select * from emp order by ename, job; EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO ---------- ---------- --------- ---------- --------- ---------- ---------- ---------- 7876 ADAMS CLERK 7788 23-MAY-87 1100 20 7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30 7698 BLAKE MANAGER 7839 01-MAY-81 2850 30 7782 CLARK MANAGER 7839 09-JUN-81 2450 20 7902 FORD ANALYST 7566 03-DEC-81 3000 20 7900 JAMES CLERK 7698 03-DEC-81 950 30 7566 JONES MANAGER 7839 02-APR-81 2975 20 7839 KING PRESIDENT 17-NOV-81 5000 20 7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30 7934 MILLER CLERK 7782 23-JAN-82 1300 20 7788 SCOTT ANALYST 7566 19-APR-87 3000 20 7369 SMITH CLERK 7902 17-DEC-80 800 20 7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30 7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30 14 rows selected. SQL> select * from emp order by ename, job desc; EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO ---------- ---------- --------- ---------- --------- ---------- ---------- ---------- 7876 ADAMS CLERK 7788 23-MAY-87 1100 20 7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30 7698 BLAKE MANAGER 7839 01-MAY-81 2850 30 7782 CLARK MANAGER 7839 09-JUN-81 2450 20 7902 FORD ANALYST 7566 03-DEC-81 3000 20 7900 JAMES CLERK 7698 03-DEC-81 950 30 7566 JONES MANAGER 7839 02-APR-81 2975 20 7839 KING PRESIDENT 17-NOV-81 5000 20 7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30 7934 MILLER CLERK 7782 23-JAN-82 1300 20 7788 SCOTT ANALYST 7566 19-APR-87 3000 20 7369 SMITH CLERK 7902 17-DEC-80 800 20 7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30 7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30 14 rows selected.
Search in this example, you will see the difference
SQL> create table test_order (name varchar2(10), surname varchar2(10), age number); Table created. SQL> insert into test_order values('Kamran','Agayev',26); 1 row created. SQL> insert into test_order values('Kamran','Taghiyev',26); 1 row created. SQL> insert into test_order values('John','Kevin',23); 1 row created. SQL> select * from test_order; NAME SURNAME AGE ---------- ---------- ---------- Kamran Agayev 26 Kamran Taghiyev 26 John Kevin 23 SQL> select * from test_order 2 order by age; NAME SURNAME AGE ---------- ---------- ---------- John Kevin 23 Kamran Agayev 26 Kamran Taghiyev 26 SQL> select * from test_order 2 order by age asc, surname desc; NAME SURNAME AGE ---------- ---------- ---------- John Kevin 23 Kamran Taghiyev 26 Kamran Agayev 26 SQL>
When in the second query, I sorted out only for age, you saw it there two 26 years old Keita, there was first Agayev, then Taghiyev. But if I want to get the family names in descending order when there are two very old person, then I will add the second column in the order by clause
- - - - - - - - - - - - - - - - - - - - -
Kamran Agayev a. (10g OCP)
http://kamranagayev.WordPress.com -
A question about the analytical function used with the GROUP BY clause in SHORT
Hi all
I created the following table named myenterprise
If I want to find which is the total sales by city? I'll run the following queryCITY STOREID MONTH_NAME TOTAL_SALES ---------- ---------- ---------- ---------------------- paris id1 January 1000 paris id1 March 7000 paris id1 April 2000 paris id2 November 2000 paris id3 January 5000 london id4 Janaury 3000 london id4 August 6000 london id5 September 500 london id5 November 1000
that works very well and produces the expected result, i.e.SELECT city, SUM(total_sales) AS TOTAL_SALES_PER_CITY FROM myenterprise GROUP BY city ORDER BY city, TOTAL_SALES_PER_CITY;
Now in one of my books SQL (Mastering Oracle SQL) I found another method by using the SUM, but this time as an analytic function. Here's what the method of the book suggests as an alternative to the problem:CITY TOTAL_SALES_PER_CITY ---------- ---------------------- london 10500 paris 17000
I know that the analytic functions are executed after the GROUP BY clause has been transformed completely and Unlike regular aggregate functions, they return their result for each line belonging to the partitions specified in the partition clause (if there is a defined partition clause).SELECT city, SUM(SUM(total_sales)) OVER (PARTITION BY city) AS TOTAL_SALES_PER_CITY FROM myenterprise GROUP BY city ORDER BY city, TOTAL_SALES_PER_CITY;
Now my problem is that I do not understand what we have to use two functions SUM? If we only use one only, i.e.
This generates the following error:SELECT city, SUM(total_sales) OVER (PARTITION BY city) AS TOTAL_SALES_PER_CITY FROM myenterprise GROUP BY city ORDER BY city, TOTAL_SALES_PER_CITY;
The error is generated for the line 2 column 11 which is, for the expression SUM (total_sales), well it's true that total_sales does not appear in the GROUP BY clause, but this should not be a problem, it has been used in an analytical function, so it is evaluated after the GROUP BY clause.Error starting at line 2 in command: SELECT city, SUM(total_sales) OVER (PARTITION BY city) AS TOTAL_SALES_PER_CITY FROM myenterprise GROUP BY city ORDER BY city, TOTAL_SALES_PER_CITY Error at Command Line:2 Column:11 Error report: SQL Error: ORA-00979: not a GROUP BY expression 00979. 00000 - "not a GROUP BY expression" *Cause: *Action:
So here's my question:
Why use SUM (SUM (total_sales)) instead of SUM (total_sales)?
Thanks in advance!
:)
In case you are interested, that's my definition of the table:
Edited by: dariyoosh on April 9, 2009 04:51DROP TABLE myenterprise; CREATE TABLE myenterprise( city VARCHAR2(10), storeid VARCHAR2(10), month_name VARCHAR2(10), total_sales NUMBER); INSERT INTO myenterprise(city, storeid, month_name, total_sales) VALUES ('paris', 'id1', 'January', 1000); INSERT INTO myenterprise(city, storeid, month_name, total_sales) VALUES ('paris', 'id1', 'March', 7000); INSERT INTO myenterprise(city, storeid, month_name, total_sales) VALUES ('paris', 'id1', 'April', 2000); INSERT INTO myenterprise(city, storeid, month_name, total_sales) VALUES ('paris', 'id2', 'November', 2000); INSERT INTO myenterprise(city, storeid, month_name, total_sales) VALUES ('paris', 'id3', 'January', 5000); INSERT INTO myenterprise(city, storeid, month_name, total_sales) VALUES ('london', 'id4', 'Janaury', 3000); INSERT INTO myenterprise(city, storeid, month_name, total_sales) VALUES ('london', 'id4', 'August', 6000); INSERT INTO myenterprise(city, storeid, month_name, total_sales) VALUES ('london', 'id5', 'September', 500); INSERT INTO myenterprise(city, storeid, month_name, total_sales) VALUES ('london', 'id5', 'November', 1000);
It is clear that thet Analytics is reduntant here...
You can even use AVG or any analytic function...SQL> SELECT city, 2 avg(SUM(total_sales)) OVER (PARTITION BY city) AS TOTAL_SALES_PER_CITY 3 FROM myenterprise 4 GROUP BY city 5 ORDER BY city, TOTAL_SALES_PER_CITY; CITY TOTAL_SALES_PER_CITY ---------- -------------------- london 10500 paris 17000
-
Documentation about adding column with the DEFAULT value.
Hello
http://download.Oracle.com/docs/CD/B19306_01/server.102/b14200/statements_3001.htm#i2198241
< quote >
If you add a column, then the initial value of each row in the new column is NULL unless you specify the DEFAULT clause. In this case, Oracle database updates each row in the new column with the value specified for the DEFAULT value. This update operation, in turn, triggers AFTER UPDATE triggers defined on the table.
< quote >
I am not able to understand the emphasis on the part AFTER UPDATE while the column with DEFAULT values addition triggers both BEFORE and AFTER triggers defined on UPDATE.
According to the documents of 11 g
http://download.Oracle.com/docs/CD/B28359_01/server.111/b28286/statements_3001.htm#i2133105
n.m. (u) r only changes with the NON NULL columns, but focus on AFTER UPDATE is still there. No trigger defined on the fire of the update in this case.
This insistence is intended? If not, IMO, it should be changed.
Kind regardsHi Sissi. After further discussion, we have added some information about a change in behavior. Here is what says the next version of the doc:
When you add a column, the initial value of each row in the new column is null.
* If you specify the DEFAULT clause for a column NOT NULL, then the default value is stored as metadata, but the column itself is not populated with data. However, the following queries that specify the new column are rewritten so that the default value is returned in the result set.
This optimized behavior differs from earlier versions, when as part of operation ALTER TABLE Oracle database updated every line in the newly created with the default column and then fired defined update triggers on the table. In this release, no trigger is triggered because the default value is stored only in the form of metadata.
* If you specify the DEFAULT for a nullable column clause, then the default value is added to existing lines under this ALTER TABLE statement, and any update triggers defined on the table are activated. This behavior also means if you change a NOT NULL column with a default value to be nullable.
Hope that helps to clarify the matter further.
Kind regards
Diana -
doubts about adding users to the Group
Hello
I'm working on obiee10g.
"Group is created in settings-> Admin-> manage the catalogue presentation groups and users.
For each access Group privileges is assigned in 'Manage privileges'.
Now, there's a table in the schema that is created which stores the group with assigned users.
The table was already created by someone else.
But we know that ' users can be added to the group using the UI of the use of OBIEE settings-> Admin-> Manage presentation catalog groups and users ' directly.
I just want to know by experts, what may be the reason behind the creation of the table for the same purpose to store users?
Thank youNo it's not. Just to make it clearer,
How it works is that, once the authentication has been made by the SSO application engine, the user id is passed to the OBI and captured in the HTTP header on the web server OBI. This user id is used as an input to extract the different parameters of the external Table(as in discussion). The web group to which the user has access to is also extracted as parameters.
After that, the system for webgroups session variable is set with the value retrieved, and so the access control is assured.
In a summary, the authorization part must also be implemented using the external table as well. The mapping of id of the user with the role (web group) are there in the table and recovered in the same block of initialization.
Just to mention, web groups would still be created in OBI BAU only.
It would be rather convenient for you in view of the current implementation, you got.
P.S.: Please note the answers with points always a good practice :)
-
CFQUERYPARAM tag does not work in the GROUP BY clause
I get an error whenever I put a CFQUERYPARAM tag in a GROUP BY clause. I saw on another forum, someone had a similar problem with the ORDER BY clause
Here's a sample of what might look like my code
Select x, y, z of ABC
Group of < cfqueryparam value = 'x' cfsqltype = "cf_sql_float" >
Here is the error I get.
Run database query error.
[Macromedia] [Oracle JDBC Driver] [Oracle] ORA-00979: not a GROUP BY expression
Any idea?Cachedwithin and cachedafter functions store the query results in the RAM of the server. This means that, even if it is cached, when you run it, you get the cached result instead of going to the database to run again. This increases the speed of course, but if the data is changed during the period of cover, you have accuracy problems.
It creates no memory problems. In the administrator you book a certain amount of memory for the query cache. If you exceed this amount, the last request to shoot the first query on, or something like that.
In regards to what you're trying to do on the binding of variables to your group by clause, this isn't what cfqueryparam has been designed for. It has been designed to
where clauses (where it =
or insert queries (insert in my values in the table (field) ())
and things like that.You try to use it for anything other than what it was designed for, which explains why it does not work for you.
-
adding column to the flow table
Hi all
I want to add a column to a table that is replicated to another database of flow.
We are using Oracle 10 G database R4.
There will be a gap of min 30 minutes to add the column to the time the database.
ADR generated on both databases during the 30 min period will come out error when applying to another DB.
How can I handle this case?
Thank you
DRI don't think I understand your explanation but your replication is not a multimaster while there should be no problem to add the DML.
Leave the current rule for such DML what and just add a new temporary rule on the two specific DDL site:
to do this, extract the name of capture and apply their queue_name respective and with dbms_streams_adm.add_table_rules on both capture and apply a site, set:
-include_dml = false
-include_ddl = trueYou have now 2 rules of the game of rules associated with each name of water course: for the DDL and DML. Make the change to the table on the source and check that it is done on the target. Then, remove this specific DDL of each rule set. Make sure the setting apply i 'COMMIT_SERIALIZATION' is set to Full.
As it's done in a pipe of the SNA you shouldn't have any problems of data found ORA-1403 due the columns found on the target and worthless in the CSF or conversely, your column will be added and fill in the same order as on the source.
-
PS Query - subtraction in the Group By Clause
Hello!!!
I have according to requirement. My PS query is seen 3 columns with the following values.
Col1 Col2 Col3
K1 8 2
K1 8 2
K1 8 2
Requirement was to have the sum of Col3. So I modified the query using SUM (Col3) as aggregate expression. Now my output looks like
Col1 Col2 Col3
K1 8 6
Now... I want the 4th column that will be the Col2 - Col3 subtraction so that the output looks like
Col1 Col2 Col3 Col4
K1 8 6 2
I use VIEW and implement this but I want to know if this can be achieved using the PS query. I also tried to use expression but his does not work.
You should be able to create an expression.
Check the aggregation function on the output Expression property page and enter the Expression as text
Max (col2) - Sum (Col3)
and, of course, define the properties of Type of the Expression and the length of the appropriate values.
Kind regards
Bob
-
adding columns in the table by trigger
Hello
I, ve found a better way of this using triggers. I'm using Oracle XE 11.2 billion, with an interactive report and a standard form.
APEX 4.0.2. I tried using SQLDeveloper:
CREATE OR REPLACE TRIGGER TRIGGER1
PRIOR TO THE UPDATE OF THE AMOUNT, TOTAL_QUANTITY ON STOCK_CONTROL
FOR EACH LINE
BEGIN
TOTAL_QUANTITY_: = AMOUNT + TOTAL_QUANTITY;
END TRIGGER1;
with message
Error (5.1): PL/SQL: statement ignored
Error (5.1): PLS-00201: identifier 'TOTAL_QUANTITY_' must be declared
I have tried variations of this but still no result, can't get the syntax right, can help anyone?
Thank you
TimAssuming that TOTAL_QUANTITY_ is already a column in the STOCK_CONTROL table:
: NEW. TOTAL_QUANTITY_: = : NEW. AMOUNT + : NEW. TOTAL_QUANTITY;
SY.
-
APEX dear users,.
In a report, I want to display a column only for a certain group of users.
How can I do this?
Thanks for your advice.
Greetz, friedSchema for this use. Create an athorization and go into the column / security. Choose the authorisation scheme there.
Denes Kubicek
-------------------------------------------------------------------
http://deneskubicek.blogspot.com/
http://www.Opal-consulting.de/training
http://Apex.Oracle.com/pls/OTN/f?p=31517:1
http://www.Amazon.de/Oracle-Apex-XE-Praxis/DP/3826655494
------------------------------------------------------------------- -
NEED HELP IN THE GROUP BY CLAUSE CASES PLEASE
User1983440 thanks for the help with the script below grouped by product category, can you or someone else help me group by another Case statement as well.
WITH p AS)
Select distinct
partner, region, od. ORDER_AFFILIATE_NAME,
Oh.external_order_number,
Ain.get_g1 (queue_type) offers,
Case
When disp.category = 100 Then 'ORDER'
When disp.category = 200 Then 'ACCESS'
When disp.category = 300 Then 'DSL'
When disp.category = 600 Then 'IPTV'
"When disp.category = 700 Then'INTERNET"
When disp.category = 800 Then 'VOIP'
End up like product_category,
To_char(OH.created_ts, 'yyyy-mm-dd HH24:mi:ss') CREATE_DATE
-Case when ip.offer_type = "IPDSLAM" or instr (ip.display_name, "-d") > 0
THEN 'IP - LAN'
ELSE 'FTTN.
end as product_type
Case
When disp.state = 4 and disp.state = 9 or disp.state = 21 or 22 = disp.state then 'cancelled '.
When disp.state = 17 then "NRFC cancelled.
When disp.state = 7 Then 'incomplete '.
When disp.state = 3 or disp.state = 8, then "Finish".
When disp.state = 6 or disp.state = 10 and disp.state = 13 or disp.state = 14 then 'pending - other ".
When disp.state = 19 disp.state = 20 then "sent".
When disp.state = 21 or disp.state = 22 then "Cancelled - CSUS.
When disp.state = 23 or 24 = disp.state then 'Order Confirmation '.
When disp.state = 1 or disp.state = 2 or disp.state = 15 then "receipt".
Another 'other '.
End as STATE_desc
of AIN.impl_oh_order_header oh,.
Ain.impl_order_data od,
DISP AIN.sncr_order_curr_disp,
AIN.impl_package ip
where oh.created_ts between to_date ('2013-02-04', ' yyyy-mm-dd "")
and to_date ('2013-02-11', ' yyyy-mm-dd "")
and oh.order_type = 'COMMAND '.
and disp.category to (200, 300, 600, 700, 800)
and disp.state! = '5'
and uscs = 0
and disp.transaction_id = oh.transaction_id
and od. transaction_id = oh.transaction_id
and ip.transaction_id = oh.transaction_id
and ip.package_type = 'PACKAGE '.
and ip.parent_package_id is null
and ip.product_type = 'COMMAND '.
)
SELECT product_category,
COUNT (*)
P
GROUP BY product_categoryTo summarize, by category of product, and then by state_desc:
WITH p AS ( Select distinct partner, region, od.ORDER_AFFILIATE_NAME, oh.external_order_number, ain.get_g1(queue_type) offer, Case When disp.category = 100 Then'ORDER' When disp.category = 200 Then'ACCESS' When disp.category = 300 Then'DSL' When disp.category = 600 Then'IPTV' When disp.category = 700 Then'INTERNET' When disp.category = 800 Then'VOIP' End as product_category, TO_CHAR(oh.created_ts, 'yyyy-mm-dd hh24:mi:ss') CREATE_DATE, Case when ip.offer_type = 'IPDSLAM' or instr(ip.display_name, '- D')> 0 THEN 'IP-DSL' ELSE 'FTTN' end as product_type, Case When disp.state = 4 or disp.state = 9 or disp.state= 21 or disp.state= 22 Then 'Canceled' When disp.state = 17 Then 'Canceled NRFC' When disp.state = 7 Then 'Incomplete' When disp.state = 3 or disp.state = 8 Then 'Complete' When disp.state = 6 or disp.state = 10 or disp.state = 13 or disp.state =14 Then 'Pending - Other' When disp.state = 19 or disp.state = 20 Then 'Submitted' when disp.state = 21 or disp.state = 22 then 'Cancelled- CSUS' when disp.state =23 or disp.state = 24 then 'Order Confirmation' when disp.state =1 or disp.state = 2 or disp.state = 15 then 'Received' Else 'Other' End as STATE_desc from AIN.impl_oh_order_header oh, ain.impl_order_data od, AIN.sncr_order_curr_disp disp , AIN.impl_package ip where oh.created_ts between to_date('2013-02-04', 'yyyy-mm-dd') and to_date('2013-02-11', 'yyyy-mm-dd') and oh.order_type = 'ORDER' and disp.category in (200, 300, 600, 700, 800) and disp.state !='5' and uscs= 0 and disp.transaction_id = oh.transaction_id and od. transaction_id = oh.transaction_id and ip.transaction_id = oh.transaction_id and ip.package_type = 'PACKAGE' and ip.parent_package_id is null and ip.product_type = 'ORDER' ) SELECT product_category, STATE_desc, COUNT(*) FROM p GROUP BY product_category, STATE_desc
To summarize by state_desc, just remove "product category", the query above.
-
I have a table that is defined as follows.
unique_number NOT NULL VARCHAR2 (64).
input_unique_number VARCHAR2 (64).
source_system VARCHAR2 (40),
end_system VARCHAR2 (40),
type VARCHAR2 (32),
date_time_sent TIMESTAMP (6).
transaction_name VARCHAR2 (60)
type input, output and does not
For each input message that a unique_number is generated, it will be populated source_sytem value but not end_sytem value
For each output message a unique_number is generated and will be input_unique_number identical to that of the input message.
For each message output of the values source_system and end_system are met.
I am trying to create a report that will give the entry, exit and County having failed for each end site, but output is to get the empty ID for the input_messages
Select
Count (case when ' entry', then Unique_id) end as I have.
(type of case when 'out' then end Unique_id) be counted as O,.
count (type of case when 'failed' then end Unique_id) f.
transaction_name,
end_system
of message_table
where to_char (date_time_sent, "DD-MON-YY HH24:MI:SS) between May 18, 11% 09' and 19 May 11 11% '
and source_system = '& Source_system'
Transaction_name group, end_system
ORDER BY end_system;
I got the following result
I O F TRANSACTION_Name END_SYSTEM
---------------------------------------------------------------------------
0 11 0 DistProdQualityEvent EANCM5051256614152
11 0 22 DistProdQualityEvent EANCM
1 0 0 DistInventoryReport EANCM5051351029368
1 0 DistInventoryReport 0 EANCM
But I'm trying since release something like that
I O F TRANSACTION_Name END_SYSTEM
---------------------------------------------------------------------------
22 11 11 DistProdQualityEvent EANCM5051256614152
1 1 0 DistInventoryReport EANCM5051351029368
Can you please let me know is a such output is possible or notWithout seeing the underlying data, it is difficult to be sure, but I guess that this is due to later...
(1) entry has no match messages and messages that fail don't have not populated end_system: it seems that this is the case for BatchCntrlNotify, NotifyProductCatalog and NotifyShippingOrder
(2) input messages do not correspond to output messages or down: it seems that this is the case for OAGSyncCustPartyMaster and POConfirmationOnly in case you released successful message that you have an end_system.
Published by: Malloy June 7, 2011 03:58
-
added column with the range?
Hello
Is it possible to add a column that can have only a range of values?, ex: Descr_tbl, I need to add the code and descr with id and columns as a composite key identification code and also I need to have the values of code between only 0-63.Like this:
SQL> create table t (n number); Table created. SQL> alter table t add constraint t_chk check (n >= 0 and n <= 63); Table altered. SQL> insert into t values (0); 1 row created. SQL> insert into t values (42); 1 row created. SQL> insert into t values (63); 1 row created. SQL> insert into t values (66); insert into t values (66) * ERROR at line 1: ORA-02290: check constraint (SCOTT.T_CHK) violated SQL> insert into t values (-5); insert into t values (-5) * ERROR at line 1: ORA-02290: check constraint (SCOTT.T_CHK) violated
Maybe you are looking for
-
I tried to download firefox without success
I have windows 7 Home Edition I use IE9 but I couldn't download fire fox, it seems out of the icon on the screen but it doesn't, so is not properly downloadI tried several times without success
-
Hello I plan to re - setup my server and the only that I'm not 100% on my migration process correctly data Mail. Can anyone confirm is my process will work or need adjustments? Export users from the Open Directory Server Open Server.app and select us
-
To replace my Hp pavilion dv6-6155tx mother
Hello I have a Hp Pavilion dv6-6155tx laptop computer with processor i5. My problem is the keyboard on the motherboard slot is damaged, and it's not fixed. So now I have two options left, can I use a USB keyboard or change the motherboard. If I want
-
Runtime 216 to 3A2A0A35 error each time I close the browser.
Original title: Runtime 216 to 3A2A0A35 error. I mean Runtime 216 3A2A0A35 error whenever I close the browser. How should I do?
-
News of the computer: HP Pavilion Notebook PC, AMD Turion x 2 Ultra Dual Core Processor ZM-82 (2.2 GHz, 2 MB L2 Cache) Hard drive 320 GB 4096 MB DDR2 SDRAM Windows Vista Edition Home Premium with Service Pack 1 - with Student Windows Package 2007 12