Improve a simple query
Here's a simple query, what I want to know, I added superior select d.name, which is the description of region_code for. Can I get a whole result with a single statement selectSELECT t.region_code, d.name, t.emp_contr
Of
(SELECT c.br_region_fo_code as Region_Code,
Sum (c.employer_contribution) AS emp_contr
OF core_business.cb_contr_emp_pmt_slip c
T GROUP BY c.br_region_fo_code),
general_information.cb_region_fo d
WHERE t.br_region_fo_code = d.region_fo_code;
Try this:
SELECT c.br_region_fo_code as Region_Code,
d.name,
SUM(c.employer_contribution) OVER(PARTITION BY c.br_region_fo_code ORDER BY c.br_region_fo_code) AS emp_contr
FROM core_business.cb_contr_emp_pmt_slip c,
general_information.cb_region_fo d
WHERE
c.br_region_fo_code = d.region_fo_code;
Tags: Database
Similar Questions
-
A simple query with as wrong return result
Hello
I run a simple query with like.
If I use the parameter I get incorrect results.
If I use the request without parameter results are ok.
My script:
ALTER SESSION SET NLS_SORT = BINARY_CI;
ALTER SESSION SET NLS_COMP = LINGUISTIC;
-drop table abcd;
create table abcd (col1 varchar2 (10));
INSERT INTO VALUES ABCD ('122222');
insert into abcd values ('111222');
SELECT * FROM ABCD WHERE COL1 LIKE: 1. -bad result with 12%
/*
COL1
----------
122222
* 111222 *.
*/
"Select * ABCD where col1 like 12%; -result ok
/*
COL1
----------
122222
*/
I use Oracle Database 11 g Enterprise Edition Release 11.2.0.1.0 - 64 bit Production
and query, run in Oracle SQL Developer 3.1.07.I think it's just a bug, and it is set to 11.2.0.3:
11.2.0.1:
DB11.2.0.1>> select * from v$version where rownum=1; BANNER -------------------------------------------------------------------------------- Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production 1 row selected. DB11.2.0.1>> ALTER SESSION SET NLS_SORT=BINARY_CI; Session altered. DB11.2.0.1>> ALTER SESSION SET NLS_COMP=LINGUISTIC; Session altered. DB11.2.0.1>> create table abcd (col1 varchar2(10)); Table created. DB11.2.0.1>> INSERT INTO ABCD VALUES ('122222'); 1 row created. DB11.2.0.1>> insert into abcd values ('111222'); 1 row created. DB11.2.0.1>> VARIABLE A1 VARCHAR2(10); DB11.2.0.1>> EXEC :A1 := '12%'; PL/SQL procedure successfully completed. DB11.2.0.1>> SELECT * FROM ABCD WHERE COL1 LIKE :A1; COL1 ---------- 122222 111222 2 rows selected.
11.2.0.3:
DB11.2.0.3>> select * from v$version where rownum=1; BANNER -------------------------------------------------------------------------------- Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production 1 row selected. DB11.2.0.3>> ALTER SESSION SET NLS_SORT=BINARY_CI; Session altered. DB11.2.0.3>> ALTER SESSION SET NLS_COMP=LINGUISTIC; Session altered. DB11.2.0.3>> create table abcd (col1 varchar2(10)); Table created. DB11.2.0.3>> INSERT INTO ABCD VALUES ('122222'); 1 row created. DB11.2.0.3>> insert into abcd values ('111222'); 1 row created. DB11.2.0.3>> VARIABLE A1 VARCHAR2(10); DB11.2.0.3>> EXEC :A1 := '12%'; PL/SQL procedure successfully completed. DB11.2.0.3>> SELECT * FROM ABCD WHERE COL1 LIKE :A1; COL1 ---------- 122222 1 row selected.
Kind regards
Sayan Malakshinov
http://orasql.org -
Not sure if I can do this with a simple query.
CREATE TABLE primary_table (SSN VARCHAR2 (15) VARCHAR2 (30) FIRST_NAME, LAST_NAME VARCHAR2 (30), VARCHAR2 (20)) of the STATE;
insert into primary_table VALUES ('111-11-1111, 'Elvis', 'Presley', 'ACTIVE');
insert into primary_table VALUES (222-22-2222', 'Gift', 'King', 'ACTIVE');
insert into primary_table VALUES ('33-333-3333, 'Lex', 'Harrison', 'ACTIVE');
CREATE TABLE secondary_table (SSN VARCHAR2 (15) NOT NULL, ARRIVAL DATE, NUMBER of LENGTH_OF_STAY);
insert into secondary_table VALUES ('11-111-1111 ", 1 January 2011", 10);
insert into secondary_table VALUES (' ' 222-22-2222 ", March 1, 2011", 10);
insert into secondary_table VALUES (' ' 222-22-2222 ", June 1, 2011", 20);
insert into secondary_table VALUES ('' 33-333-3333, January 1, 2011 ", 10);
========================================================================================
Hello
I created two very simple tables for this exercise. I don't know if I can do this with a simple query, or must use pl/sql.
I want to join primary_table secondary_table of SSNand list the fields of primary_table, but only if the join returns only a line.
In other words, I would like to create a list of data primary_table for primary_table lines that have only one line on the secondary table.
ConcerningRF25 wrote:
CREATE TABLE primary_table (SSN VARCHAR2 (15) VARCHAR2 (30) FIRST_NAME, LAST_NAME VARCHAR2 (30), VARCHAR2 (20)) of the STATE;insert into primary_table VALUES ('111-11-1111, 'Elvis', 'Presley', 'ACTIVE');
insert into primary_table VALUES (222-22-2222', 'Gift', 'King', 'ACTIVE');
insert into primary_table VALUES ('33-333-3333, 'Lex', 'Harrison', 'ACTIVE');CREATE TABLE secondary_table (SSN VARCHAR2 (15) NOT NULL, ARRIVAL DATE, NUMBER of LENGTH_OF_STAY);
insert into secondary_table VALUES ('11-111-1111 ", 1 January 2011", 10);
insert into secondary_table VALUES (' ' 222-22-2222 ", March 1, 2011", 10);
insert into secondary_table VALUES (' ' 222-22-2222 ", June 1, 2011", 20);
insert into secondary_table VALUES ('' 33-333-3333, January 1, 2011 ", 10);========================================================================================
Hello
I created two very simple tables for this exercise. I don't know if I can do this with a simple query, or must use pl/sql.
I want to join primary_table to secondary_table of NSSand the list of fields in the primary_table, but only if the join returns only a line.
In other words, I would like to create a list of data primary_table for primary_table lines that have only one line on the secondary table.
Concerning
Something like...
select p.
from primary_table p where p.ssn in (select s.ssn from secondary_table s group by s.ssn having count(*) = 1) -
Hello, I'll start by saying that I am a noob. in any case, I'm trying to do what I thought was a simple query for records that are greater or equal to the date of the day: it's my request...
< cfquery name = "getUpcoming" datasource = 'events' >
SELECT title, eventDate FROM event WHERE eventDate > = #Now () # ORDER BY ASC eventDate
< / cfquery >It works, so, I get the records that are greater than the current date, but all records that match to are not.
I guess that it is looking at the time as well, or should I completely wrong. I do not know? Any help would be greatly appreciated.
Good reading up on top of
(http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7f 6f.html), which you must use when you pass dynamic values to the DB, instead of hard-coding the in your SQL string. And when using , use a param of CF_SQL_DATE type, and must ignore the time portion of the date/time value, you pass (I'm not 100% certain of this... only about 99% certain... but give it a go). Or spend only the date part of the date/time value in the query. Using createOdbcDate() fact, without all the extra horsing around adding things together and using the dateFormat() attribute as the previous poster suggested. --
Adam
-
Simple query in Oracle Table in MS Access causes a full table scan.
I run a very simple query in MS ACCESS to an Oracle table attached as follows:
Select *.
EXPRESS_SERVICE_EVENTS-(EXPRESS is the name of the related table. SERVICE_EVENTS)
When executed > MyDate()
or
Select *.
EXPRESS_SERVICE_EVENTS-(EXPRESS is the name of the related table. SERVICE_EVENTS)
When executed > [Forms]! [MyForm]! [Date1]
We have more than 50 machines and this query works well on more than half of them, using an Oracle Index on the field "run." Exactly the same thing running on other machines results in a full table scan, so regardless of the index (the DB access even access all machines).
Strangely, if we write the query as follows:
Select *.
Of EXPRESS_SERVICE_EVENTS
When executed > # 2009-09-04 08:00 #.
It works fast everywhere!
Any help with this "phenominon" would be appreciated.
We did the things:
Check the locale settings of the ODBC driver, MS Access settings (as in tools-> Options), we have the latest XP and Office service packs and re-related all the Access Tables on the slow and fast machines independently).All machines use the same version of the ODBC driver?
If you have access to Metalink, check the following note:
Note.257828.1 Scan of Table full Ext/Pub while seeking the DATE columns using the ODBC Oracle driver:In a Word, try "bind timestamp date" option in the dsn configuration and do not forget to update the links in the table.
It will be useful,
Greg -
Improve a simple select query that uses all the lines.
Hi all
Excuse me if the question is too dumb. Here is my code
The query uses all records in the CREDIT_CARD_PYMT_DTLS table. Transaction type will be either 'C' or '.SQL> select * from v$version; BANNER ---------------------------------------------------------------- Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod PL/SQL Release 10.2.0.1.0 - Production CORE 10.2.0.1.0 Production TNS for 32-bit Windows: Version 10.2.0.1.0 - Production NLSRTL Version 10.2.0.1.0 - Production Elapsed: 00:00:00.07 SQL> show parameter optim NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ object_cache_optimal_size integer 102400 optimizer_dynamic_sampling integer 2 optimizer_features_enable string 10.2.0.1 optimizer_index_caching integer 0 optimizer_index_cost_adj integer 100 optimizer_mode string ALL_ROWS optimizer_secure_view_merging boolean TRUE plsql_optimize_level integer 2 SQL> explain plan for select SUM(decode(transaction_type,'D',txn_amount,0)) payments_reversals, 2 SUM(decode(transaction_type,'C',txn_amount,0)) payments,primary_card_no,statement_date 3 from credit_card_pymt_dtls group by primary_card_no,statement_date; Explained. SQL> select * from table(dbms_xplan.display); PLAN_TABLE_OUTPUT ----------------------------------------------------------------------------------------------------------------------- ----------------------------------- Plan hash value: 2801218574 ---------------------------------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time | ---------------------------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 1912K| 56M| | 21466 (3)| 00:04:18 | | 1 | SORT GROUP BY | | 1912K| 56M| 161M| 21466 (3)| 00:04:18 | | 2 | TABLE ACCESS FULL| CREDIT_CARD_PYMT_DTLS | 1912K| 56M| | 4863 (3)| 00:00:59 | ---------------------------------------------------------------------------------------------------- 9 rows selected. SQL> select index_name,index_type 2 from all_indexes 3 where table_name = 'CREDIT_CARD_PYMT_DTLS'; INDEX_NAME INDEX_TYPE ------------------------------ -------------------- INDX_TRANTYPE BITMAP INDX_PCARD NORMAL INDX_PSTATEMENT_DATE NORMAL
CREDIT_CARD_PYMT_DTLS has 2 million lines and the qury will display 1.5 million lines. Table statisticas are up to date.
The query takes now almost 5 minutes. Y thaere a way to reduce the time?
Our DB server has 8 processors and 8 GB of memory. Is it authentic?
Thanks in advance.
Published by: user11115924 on April 29, 2009 02:43
All columns used in the query are already indexed. (Of course, not only for this query.)I should not get too hung up the full Table Scan necessarily - Oracle makes a decision, and even with your new index, he still thinks it is the most effective way to recover the data.
Did you collect statistics on this new index?
You have created the index with:
TO_CHAR("STATEMENT_DATE",'MON-RRRR')
Yet, you seem to be just by selecting statement_date in your query: Oracle cannot use the index (according to functions) in this case!
If you have only a small number of columns in this table, you can consider an Table of Index organized (ITO), then the table itself is a clue.
I'd be more inclined to optimize the complete analysis of the table and the creation of other clues, I would say, have you tried the PARALLEL tip?
-
Choice of the message can be changed in the table of search results Simple query region?
Hi friends,
I have a Simple search query region in 11i.
I created the SearchVO and bound to the query Table Region.
I have two attributes MessageStyleText and a MessageChoice attribute in the simple search criteria.
Search results show very well for all attributes.
But when I search with the criteria of MessageChoice, in the table of results, this attribute MessageChoice is indicated as editable, display the drop-down list.
I did this attribute ReadOnly = True but then it becomes readonly in search also. So this dosent help.
I need to this drop-down list of MessageChoice be modifiable in the search criteria, but read in the table of results.
Please help me with the resolution. Its kinda urgent.
Would appreciate any help.
Thank you
Rajesh
He solved.
Added programmatically in code.
Kept the attribute as MessageChoice in the query Table Region.
Added to the controller
' Public Sub processRequest (pageContext OAPageContext, OAWebBean webBean)
{
super.processRequest (pageContext, webBean);
OAM OAApplicationModule = pageContext.getRootApplicationModule ();
OAMessageChoiceBean = processFlagMessageChoice
(OAMessageChoiceBean) webBean.findChildRecursive ("AttributeId");
processFlagMessageChoice.setReadOnly (true);
}
-
simple query... but could not
CREATE TABLE person_del
(
DNO VARCHAR2 (5).
place VARCHAR2 (10),
EU VARCHAR2 (10)
)
commit;
insert into person_del values('1','home','Y')
insert into person_del values('1','office','N')
insert into person_del values('1','other','Y')
insert into person_del values('2','office','Y')
insert into person_del values ('3', 'home', 'n')
insert into person_del values ('3 ', 'Office', 'Y')
insert into person_del values ('4 ', 'other', 'n')
insert into person_del values ('5', 'home', 'Y')
insert into person_del values ('6', 'home', 'n')
insert into person_del values ('6', 'Office', 'n')
insert into person_del values ('7', 'home', 'Y')
insert into person_del values ('7 ', 'Office', 'Y')
commit;
Select * from person_del
Select the dno, place, got,
-case when am = 'Y', and then 'Y '.
Another null
end as "won".
of person_del
where to put in ("home", "office")
I ran the query above, but the result is not what I wanted
The condition is as follows:
List Y in a new column "earned" for these dno who reached the place - home or office
If a = Y for the home place and GOT = N for the Office of the place, then only view this column where OBTAINED = Y
If a = N to the home place and GOT = Y for the Office of the place, and then view only this column where OBTAINED = Y
If both are N then list a any column
If the two are then all a fo the column in the list
The place else is not taken into account
The output should be dno and won the column
I know it's simple... but I couldn't do it and I need it in a few minutes
Can someone help me on this using the CASE statement or something that is not difficult to understand the ASAP?
Basically, the output of it should be as follows:
DNO has won
1. IS
3 8
2 8
8 4
6 N
7. THEREWhat:
SQL> select dno 2 , got won 3 from ( select dno 4 , got 5 , row_number() over (partition by dno, got order by dno, got desc) cnt 6 from person_del t 7 where t.place in ('home', 'office') 8 ) 9 where ( case 10 when got = 'Y' and cnt = 1 then 1 11 when got = 'N' and cnt = 2 then 1 12 end 13 ) = 1; DNO WON ----- ---------- 1 Y 2 Y 3 Y 5 Y 6 N 7 Y 6 rows selected.
-
Why XML XML Simple query on Table Eval does not work?
I have a request that a simple select on a binary xml table on 11.2.0.1:
Now this xml document exists as a record in the binary xml table with evalId = "RickBlanchard9972" attributeSELECT xmlcast(xmlquery('$p/eval/@evalId' passing e.object_value AS "p" RETURNING CONTENT) AS VARCHAR2(30)) "EVAL ID" FROM eval e WHERE xmlexists('declare default element namespace "http://www.cigna.com/acme/domains/eval/2010/03"; /eval[@evalId=$eval_id]' PASSING object_value, 'RickBlanchard9972' as "eval_id");
Unfortunately, the query returns with a null value instead of; RickBlanchard9963<?xml version = '1.0' encoding = 'UTF-8' standalone = 'yes'?><eval createdById="1957" acmeMemberId="37e6f05a-88dc-41e9-a8df-2a2ac6d822c9" category="external" eval_dt="2012-02-11T23:47:02.645Z" evalId="RickBlanchard9963" xmlns="http://www.cigna.com/acme/domains/eval/2010/03" xmlns:ns2="http://www.cigna.com/acme/domains/derived/fact/2010/03" xmlns:ns3="http://www.cigna.com/acme/domains/common/2010/03"> <derivedFacts> <ns2:derivedFact> <ns2:defId>888</ns2:defId> <ns2:defUrn>urn:coderunner:Medical:Definition:DerivedFact:52600:2</ns2:defUrn> <ns2:factSource>CCDR Member</ns2:factSource> <ns2:origInferred_dt>2012-02-11T23:47:02.645Z</ns2:origInferred_dt> <ns2:factValue> <ns2:type>string</ns2:type> <ns2:value>null</ns2:value> </ns2:factValue> </ns2:derivedFact> <ns2:derivedFact> <ns2:defId>777</ns2:defId> <ns2:defUrn>urn:coderunner:Medical:Definition:DerivedFact:52599:1</ns2:defUrn> <ns2:factSource>CCDR Member</ns2:factSource> <ns2:origInferred_dt>2012-02-11T23:47:02.645Z</ns2:origInferred_dt> <ns2:factValue> <ns2:type>string</ns2:type> <ns2:value>INT</ns2:value> </ns2:factValue> </ns2:derivedFact> <ns2:derivedFact> <ns2:defId>666</ns2:defId> <ns2:defUrn>urn:coderunner:Medical:Definition:DerivedFact:51400:1</ns2:defUrn> <ns2:factSource>CCDR Member</ns2:factSource> <ns2:origInferred_dt>2012-02-11T23:47:02.645Z</ns2:origInferred_dt> <ns2:factValue> <ns2:type>integer</ns2:type> <ns2:value>32</ns2:value> </ns2:factValue> </ns2:derivedFact> <ns2:derivedFact> <ns2:defId>555</ns2:defId> <ns2:defUrn>urn:coderunner:Medical:Definition:DerivedFact:52177:3</ns2:defUrn> <ns2:factSource>CCDR Member</ns2:factSource> <ns2:origInferred_dt>2012-02-11T23:47:02.645Z</ns2:origInferred_dt> <ns2:factValue> <ns2:type>string</ns2:type> <ns2:value>null</ns2:value> </ns2:factValue> </ns2:derivedFact> <ns2:derivedFact> <ns2:defId>444</ns2:defId> <ns2:defUrn>urn:coderunner:Medical:Definition:DerivedFact:52075:1</ns2:defUrn> <ns2:factSource>CCDR Member</ns2:factSource> <ns2:origInferred_dt>2012-02-11T23:47:02.645Z</ns2:origInferred_dt> <ns2:factValue> <ns2:type>string</ns2:type> <ns2:value>F</ns2:value> </ns2:factValue> </ns2:derivedFact> <ns2:derivedFact> <ns2:defId>333</ns2:defId> <ns2:defUrn>urn:coderunner:Medical:Definition:DerivedFact:51392:1</ns2:defUrn> <ns2:factSource>CCDR Member</ns2:factSource> <ns2:origInferred_dt>2012-02-11T23:47:02.645Z</ns2:origInferred_dt> <ns2:factValue> <ns2:type>boolean</ns2:type> <ns2:value>true</ns2:value> </ns2:factValue> </ns2:derivedFact> <ns2:derivedFact> <ns2:defId>222</ns2:defId> <ns2:defUrn>urn:coderunner:Medical:Definition:DerivedFact:52837:2</ns2:defUrn> <ns2:factSource>CCDR CaseManagement</ns2:factSource> <ns2:origInferred_dt>2012-02-11T23:47:02.645Z</ns2:origInferred_dt> <ns2:factValue> <ns2:type>boolean</ns2:type> <ns2:value>true</ns2:value> </ns2:factValue> </ns2:derivedFact> </derivedFacts> </eval>
Must be something obvious missing here...
Any help is appreciated.
Kind regards
Rick BlanchardThe sample document contains evalId = "RickBlanchard9963", not "RickBlanchard9972" but it's probably a typo?
The real problem is that you are missing from the default namespace declaration in XMLQuery.
-
Hello! I have a simple request: NO of ROAD_TYPE = "RAMP" or NO FUNC_CODE = 7 FUNC_CODE or NOT = 0 or NOT FUNC_CODE = NULL, each element of the query by itself without problem, tracks, but linked together in this way with the GOLD, one of them opts on. What I am doing wrong?
It's the difference between OR and and.
Think about this simple example
Where Column != A or Column != B.
Excluding the Null handling, it's true. Because for the first condition, it will be true for all but one, and the second condition will be true for A. You need an AND, not a RC.
For simplicity and readability without doubt, use an In operator, and group together them. It would therefore be:
Where Road_Type != 'RAMP' and Func_Code Not In('0, 7) and Func_Code is not Null
-
Cannot get this simple query!
Hi guys,.
There is this requirement easy to write a query that selects many columns in a table, but grouped on 3 columns in the same table.
Table Str:
C11 col2 col3 col4 col5 col6 col7 col8 col9 col10
Mandatory:
Group By: Col9, col10
Columns to select: C11 col2 col3 col4 col5 col6 col7 col8
I know there is something simple that I'm missing.
any help will be appreciated.
Thank you!Hello
What produces the output you asked for the data that you have posted:
SELECT MIN (col1) , MIN (col2) , MIN (col3) , MIN (col4) , MIN (col5) , MIN (col6) , MIN (col7) , MIN (col8) , col9 , col10 FROM str GROUP BY col9 , col10 ;
If the fact
WITH got_rnum AS ( SELECT str.* , ROW_NUMBER () OVER ( PARTITION BY col9 , col10 ORDER BY col1 , col2 , col3 , col4 , col5 , col6 , col7 , col8 ) AS rnum FROM str ) SELECT col1 , col2 , col3 , col4 , col5 , col6 , col7 , col8 , col9 , col10 FROM got_rnum WHERE rnum = 1 ;
With the sample data that you posted both queries produce the same results.
With other data, both queries will produce different results. -
How to write this Simple query?
Select * from student
where
(select count (first_name) of student) > 1;
Basically I want a list of student table where the counties of first names are more than 1. However he shows me the output for
Select * from student;
any suggestions?
Hello
2776946 wrote:
Select * from student
where
(select count (first_name) of student) > 1;
Basically I want a list of student table where the counties of first names are more than 1. However he shows me the output for
Select * from student;
any suggestions?
Think about it. The subquery tells you the number of rows in all of the table have a first name. It will always tell you the number of rows in all of the table name. You don't want to know how many rows in the table have a name, you want to know how many rows in the table have the same name.
One way to do is a correlated subquery:
Select *.
student m-m is for hand query
where)
SELECT count (*)
student s-s is for the subquery
where s.first_name = m.first_name
) > 1
;
-
REGEXP_SUBSTR simple query
Hi all
Select RTRIM (REGEXP_SUBSTR('675809532|11787148|0','[a-zA-Z0-9]+\|'),'| ') double cardid
Output
--------
675809532
form above query I had the first value 675809532 how can I second valueor third value only pls help for these
I need to pass the value to the variable individally
Thank you...
By adding the occurece to the RegExp as:
Select RTRIM (REGEXP_SUBSTR ("675809532 |")) 11787148 | 0','[a-zA-Z0-9] + \| ?', 1,2),'| ') the double cardid
and the regular expression would be easier that way:
Select REGEXP_SUBSTR ('675809532 | 11787148 | 0', ' [^ \ |] +' 1, 3) double cardid
HTH
-
Problem with the simple query.
Hi all
I am facing problem with the query below
Select A.COL1, A.COL2
B.COL1, B.COL2
FROM TABLE1 A
TABLE 1 B
WHERE A.header = '123'
AND B.header = '123'
AND nvl (A.COL6, 'ABC') = 'ABC '.
AND NVL (B.COL6, 'DEF') = 'DEF '.
Basically, my requiremenyt is: I have only one table, TABLE1 here, which has a line two lines (for the same header) as "ABC" and another is "DEF". Table 1 has two columns (col1, col2) that should be displayed for both lines.
When the header has two records in table1 top query works. and but if I do not have a record for any header example there are a record for "abc" in col6 only. so my query above does not work because there is no record for 'DEF' in col6. But I want to again request to fecth the output (for b.col1 and b.col2 should have null values)
could you pls suggest me how to get the 4 columns.
Thanks in advance
Kind regards
UVA.
Try to place the status of outer join on column: analytical_criterion_code as
and nvl (AUDIT.analytical_criterion_code, 'AUDIT2') = 'verification2. '
.
.
and nvl (TRANS.analytical_criterion_code, 'TRANS2') = 'TRANS2.
In the sub query based on the opinions that you have given in post # 1, although there is no value "DEF * ' for col6 due to the condition of outer join on b.col6 (+) line is extracted with b.col [1,2,3] as NULL values. Try to remove the (+) sign b.col6 and test.
with t as)
Select 111 col1, col2 'aaa', 'ABC' col6 123 header of all the double union
Select 222 'bbb', 'DEF' col6, 123 double header
)
q as (select 123 double header)
Select A.COL1, A.COL2, A.COL6
B.COL1, B.COL2, b.COL6
q.header
T a
t b
q
where a.col6 (+) = 'ABC '.
and b.col6 (+) = "DEF."
and q.header = a.header (+)
and q.header = b.header (+)
-
Hello dear friends,
I have the table below, for the State of the field, if 0 it means that the liabilities and if 1 this means active.
I want to write a query to return users who have more active than passive users users.
I wrote this query, it is not complete and also syntax does not, correct
you would he rewrite please for me?
for current data, I want to have 2 and 3 as a result. (means the User2 and user3)
Oracle 11g.
{code}
--------------------------------------------------------
-Datei standing - Freitag-February-28-2014
--------------------------------------------------------
--------------------------------------------------------
-The DOF for Table FRIEND
--------------------------------------------------------
CREATE TABLE FRIEND
('FRIEND1' NUMBER,
'FRIEND2' NUMBER,
NUMBER OF the 'STATE '.
) CREATION OF IMMEDIATE SEGMENT
PCTFREE, PCTUSED, INITRANS 40 10 1 MAXTRANS 255
REGISTRATION OF NOCOMPRESS
STORAGE (INITIAL 57344 NEXT 57344 MINEXTENTS 1 MAXEXTENTS 2147483645)
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
USER_TABLES FLASH_CACHE, CELL_FLASH_CACHE DEFAULT DEFAULT)
TABLESPACE "STUDENT";
REM, INSERTING a FRIEND
TOGETHER TO DEFINE
Insert in a FRIEND (FRIEND1, FRIEND2, STATE) values ('1', ' 1', ' 0');
Insert in a FRIEND (FRIEND1, FRIEND2, STATE) values ('2', ' 3', 1');
Insert in a FRIEND (FRIEND1, FRIEND2, STATE) values ('3', ' 2', 1');
Insert in a FRIEND (FRIEND1, FRIEND2, STATE) values ('4', ' 5', ' 0');
Insert in a FRIEND (FRIEND1, FRIEND2, STATE) values ('3', ' 4', 1');
{/ code}
{code}
Select f1. FRIEND1 to f1, f2 friend friend where
(select count (*) in the f1 where f1.friend1 <>f1.friend2 and status = 1 f1.friend1 group) > (select count (*) f2 where f2.friend1 f2.friend2 and status = <>group by f2.friend1 0)
and f1.friend1 = f2.friend1;
{/ code}
Thank you in advance.
Hello
Of course; everything you can do with DECODE, you can also do business (and vice versa):
SELECT friend1
DE)
SELECT friend1, friend2, State
Friend
UNION - or UNION ALL
SELECT friend2, friend1, State
Friend
)
GROUP BY friend1
SEEN THE SUM (CASE
WHEN the State = 0
THEN-1
1. OTHER
END
) > 0
;
What is the problem with DECODE? What problem are you trying to solve avoiding DECODE them? Always explain why you want to do something; otherwise, you might get a solution that does what you requested, but does not solve your problem.
Is this just because the DECODING is so enigmatic: difficult to understand and so easy to get wrong? It's a good reason. This is why I almost never use DECODE; I almost always use the CASE instead. In certain situations, DECODE can be a little shorter, so, sometimes in a very complicated expressions I think DECODE is a little clearer, but this does not happen often.
Maybe you are looking for
-
FireFox would open my gmail and now it will not; That's happened?
At the same time stopped FF open my gmail account. I had added a few Add ons then tried to check my email and received the message: Firefox has detected that the server redirects the request for this address in a way that will never end. This problem
-
Satelliite C660 - HDMI connection
Hello I just bought a Toshiba Satellite C660. It has a VGA port and 2 USB ports, but not one for a HDMI cable. Can someone tell me the best way to connect my laptop to my TV to watch shows in HD quality. Sorry - I'm an amateur when it comes to this s
-
Connects Windows Mail is no longer in my Cox mail server. I can't receive or send via Windows Mail. Cox saying as long as I can use their web mail service (I can), the problem is on my end. How can I get Windows mail works again? Can I uninstall w
-
How does the Facebook SDK? How to integrate it?
Hello world I have download the sdk facebook for blackberry from this site http://www.baskoro.web.id/facebook-blackberry-sdk.html. I got the code FRO MCet site above and 'Strawberry of Blackberry' facebook application works very well in this SDK. The
-
s my lap top was working fine until I downloaded 16 updates, now, all I get is the screen of bluie before ii can type in my passwork