SELECT statement where not equal number of columns
Hi experts,I have a sum of column
id amount
1 123.0000000000
2 33344.0000
3 66666.36220000000000000000
4 2122222.7878789799999
5 444444444
6 .000000000000000000000
7 wweeeeeeeeeerr
8 eeeeeeeeeeeeeet
I want to get :
id amount
7 wweeeeeeeeeerr
8 eeeeeeeeeeeeeet
Thanks in advance
A way
with tempdata
as(select '123' amount from dual union
select 'ABC12' from dual union
select 'abc' from dual union
select '123.00' from dual )
select * from tempdata where
LENGTH(TRIM(TRANSLATE(amount, ' +-.0123456789', ' '))) is not null
Tags: Database
Similar Questions
-
Select inside a select statement is not running
Can you please explain to me why the bottom is not run and what we need to do to run this kind of scenario.
My second REGEXP_LIKE variable comes from another table
Select
* de
EMP
WHERE
NOT REGEXP_LIKE(ename, select 'LA| AR' from dual
)
Because online select statement needs to be surrounded by square brackets so that the result is regarded as a value.
SQL > ed
A written file afiedt.buf1 Select
2 of PEM
3 * WHERE NO REGEXP_LIKE (ename, (select ' THE |)) AR' double))
SQL > /.EMPNO, ENAME, JOB HIREDATE DEPTNO COMM SAL MGR
---------- ---------- --------- ---------- -------------------- ---------- ---------- ----------
7369 SMITH CLERK 7902 DECEMBER 17, 1980 00:00:00 800 20
7499 ALLEN SALESMAN 7698 20 FEBRUARY 1981 00:00:00 1600 300 30
7566 JONES MANAGER 7839 2 APRIL 1981 00:00:00 2975 20
7788, SCOTT, ANALYST, 7566 19 APRIL 1987 00:00:00 3000 20
PRESIDENT OF KING 7839 17 NOVEMBER 1981 00:00:00 5000-10
7844 TURNER SALESMAN 7698 1981 - SEP - 08 00:00:00 1500 0 30
7876 ADAMS CLERK 7788 23 MAY 1987 00:00:00 1100 20
7900 JAMES CLERK 7698 3 DECEMBER 1981 00:00:00 950 30
7902 FORD ANALYST 7566 3 DECEMBER 1981 00:00:00 3000 20
7934 MILLER CLERK 7782 23 JANUARY 1982 00:00:00 1300 1010 selected lines.
However, why not just make...
Select *.
WCP
If NOT of REGEXP_LIKE (ename, ' THE |) AR')
/
-
Select with Where not in (subselect)
Hello
Are there any special about 'no' in the ORacle sql (10g) that it returns me all the lines, unlike SQL Server with the same code:
I see that to remove < not > it works fine. is there any GOLD-> happaned plate AND with the negation?select count(*) from t1_ups where id_ups not in (select b.id_ups from t1_dups b) COUNT(*) ---------------------- 0 vs. select count(*) from t1_ups where id_ups not in ('abc', 'def','xyz') --select b.id_ups from t1_dups b) COUNT(*) ---------------------- 16 DDL: "id_ups" VARCHAR2(20 BYTE), is the same for both tables.
My overall task is to make the UNION "with replacement" when if any records exist in id_dups they will replace those of id_ups, so I try to make it into several parts.
Thank you
TR
Published by: trento on Nov 16, 2010 15:00Use NOT EXISTS instead of NOT IN.
select count(*) from t1_ups u where not exists (select b.id_ups from t1_dups b where b.id_ups= u.id_ups)
-
Select statement will not accept that so informed data date picker
In my report source region, I have the following. It works but sometimes the user want to have all the dates of: P20_XXD and: P20_DD2
But the report doesn't give you anything if you don't fill in the date two pickers.
Select
incident_id,
incident_type,
status,
ccb_identifier,
last_name,
DBMS_LOB.substr("PROBLEM_TITLE",4000,1) "PROBLEM_TITLE"
DBMS_LOB.substr("PROBLEM_DESCRIPTION",4000,1) "PROBLEM_DESCRIPTION"
create_datex,
related_item,
DBMS_LOB.substr("RESOLUTION_DIARY",4000,1) "RESOLUTION_DIARY".
of 'KEYHD '.
where "INCIDENT_TYPE" as: P20_LIST_INCIDENT_TYPE
and (CREATE_DATEX > = TO_DATE(:P20_XDD,'DD/MM/YYYY'))
and CREATE_DATEX < = TO_DATE (: P20_DD2,' DD/MM/YYYY ""))If the values of the selectors of dates are not supplied then the values null that results do not meet the date comparison predicate. NULL values must be replaced by default appropriate, for example by using the nvl function:
select incident_id, incident_type, status, ccb_identifier, last_name, dbms_lob.substr("PROBLEM_TITLE",4000,1) "PROBLEM_TITLE", dbms_lob.substr("PROBLEM_DESCRIPTION",4000,1) "PROBLEM_DESCRIPTION", create_datex , related_item, dbms_lob.substr("RESOLUTION_DIARY",4000,1) "RESOLUTION_DIARY" from "KEYHD" where "INCIDENT_TYPE" like :P20_LIST_INCIDENT_TYPE and (CREATE_DATEX >= nvl(TO_DATE(:P20_XDD,'DD/MM/YYYY'), date '-4712-01-01') and CREATE_DATEX <= nvl(TO_DATE(:P20_DD2,'DD/MM/YYYY'), date '9999-12-31'))
(Always zip code encapsulated in------)
…\
Labels to preserve formatting).
-
Formatting for a select statement
I am trying to include formatting in a select statement.
The data, I'm pulling compared to the SSN for a unique value. The problem is that the SSN is formatted with dashes in a table and not in the other.
Example:
Table 1
Name SSN
John 400-30-8745
Mary 348-00-4093
Table 2
Name SSN
John 400308745
Mary 348004093
What I would do is:
Select * into Table1, Table2 where table1.ssn = table2.ssn
However, I am unable to do so due to the formatting.
Thxs!It will not replace the data in the database because it is a SELECT statement and not a DML (INSERT, UPDATE, DELETE) statement. You can also consider putting a function based on this column in table1 index to facilitate this request. However, it depends on many factors and because we do not know the versions, estimated use, how many times the table is updated, etc., we can say with certainty whether this can help or not. An example would be:
CREATE INDEX TABLE1_SSN_FBIDX ON TABLE1(REPLACE(SSN,'-'))
-
Insert a variable + string using the select statement with cfquery
I'm doing an insertion by a select statement where the insert for one of the fields should be a combination of a vaule comes from the selection and concatenated with a string of text. Is this possible and if what the correct syntax so? Here is an example of what I'm trying, but does not.
< name cfquery = "createnote" datasource = "#application.datasource #" >
INSERT INTO gtbl_notes (notedate, strCustomerID, notetype, note, notecreatedby)
SELECT "#currentdate #", strCustomerID, "miscellaneous", "#gtbl_people.email # DELETED because of HARD BOUNCE ', 'Bounce Routine.
OF gtbl_people, gtbl_bounces
WHERE gtbl_bounces.email = gtbl_people.email AND gtbl_bounces.subscriber = 1 AND gtbl_bounces.status = 2< / cfquery >
Any input would be greatly appreciated.
Concatonation is possible with most, if not all of the databases. The syntax is a specific software and you do not your specify.
-
Insert and update by the select statement
Hi all
How can I insert and update in an oracle 10g database table
by a select statement. do not merge.Florian wrote:
Hi all
How can I insert and update in an oracle 10g database table
by a select statement. do not merge.
>How can I insert and update in a table of database oracle 10g via a select statement. do not merge.
Do you mean by using subqueries?
Something like
insert into whatever ...select statement update whatever set (column, column) = (select column, column ...)
There is a lot of information on this topic in the online documentation
-
How to ask the user to type in the select statement
Hello
Can anyone tell me the syntax of the select statement where I can ask the user to enter the value.
for example, I try to use belowthing, but it displays error
Select * from emp where empname =: empname
SP2-0552: Bind "empname' undeclared variable.
2. is there a dictionary of data table to see all pl/sql procedures and corresponding code?
Thank you
SriTry:
select * from emp where empname='&empname';
L.
-
With the help of inplace column number of the column name in the SQL Select statement
Is it possible to execute instructions select sql with the number of columns in
place names of columns?
Run SQL
Is it possibleselect AddressId,Name,City from Address
Thanks in advanceselect 1,2,5 from Address
You can extract the names of the columns for user_tab_columns
withSELECT Column_name FROM user_tab_columns where table_name = 'MY_TABLE' and Column_id in (1,2,5)
Use dynamic SQL and then the result to get the values.
But as others already mentioned, this wil it be given incorrect if your table is changed.
-
There are two select statement, which are as follows: 1) select project id, the name of ppm.pm_projects project_name and request_id 2) select id, name from request_type_name to kcrt_request_details. There is a column called entity that can store a value i.e. project or request. I want to write a select statement containing a condition that is if the entity name is project and then run the select statement 1 otherwise, if the name of the entity's request, then run the select statement 2. All this must be written in a select statement. Can someone help me how to write this select statement type.
Hello
Hello
2726057 wrote:
... There is a column called entity that can store a value i.e. project or request. ...
In which table is this column? Assuming that it is in a table called entity_table, you can do something like this:
SELECT project AS id
project name AS the name
OF ppm.pm_projects
WHEN THERE IS)
SELECT 1
Of entity_table
Entity WHERE = "Project".
)
UNION ALL
SELECT request_id ID
request_type_name AS name
OF kcrt_request_details
WHEN THERE IS)
SELECT 1
Of entity_table
Entity WHERE = 'ask '.
)
;
This does not have anything on the number of lines is entity_table, or what are the values in the column of the entity. In other words, the query works in all cases. If any line in entity_table entity = 'Project', then the pm_projects data will be included in the result set. If any line in entity_table entity = 'Request', kcrt_request_details data will be included.
I hope that answers your question.
If this isn't the case, please post a small example data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and the results desired from these data.
Explain, using specific examples, how you get these results from these data.
Always say what version of Oracle you are using (for example, 11.2.0.2.0).
See the FAQ forum: https://forums.oracle.com/message/9362002#9362002
-
How to INSERT a SELECT statement with a GROUP BY clause on a table with an IDENTITY column?
n an application, I intend to truncate and insertion on a 12 c Oracle database, but have found this problem with a
IDENTITY
column. Even if theINSERT... SELECT
statement works on mostSELECT
uses I tried, if this statement was also aGROUP BY
clause, it does not work, delivering a "ORA-00979: not aGROUP BY
expression ' complaint. Some examples of code:create table aux ( owner_name varchar2(20), pet varchar2(20) );
insert into aux values ('Scott', 'dog');
insert into aux values ('Mike', 'dog');
insert into aux values ('Mike', 'cat');
insert into aux values ('John', 'turtle');
create table T1 (
id number generated always as identity,
owner_name varchar2(20),
pet_count number );
select owner_name, count(*) as pet_count from aux group by owner_name; -- works just fine
insert into T1 (owner_name, pet_count) select owner_name, count(*) as pet_count from aux group by owner_name; -- doesn't work
The select statement works by itself, but it fails as an INSERT... SELECT statement.
Appreciate the help!
Looks like a bug. You must open the SR with Oracle. Meanwhile, you could materialize select:
SQL > insert into T1 (owner_name, pet_count)
2 with t as (select / * + materialize * / owner_name, count (*) as pet_count to the owner_name group)
3. Select owner_name, pet_count t
4.3 lines were created.
SQL > select * from t1;
ID OWNER_NAME PET_COUNT
---------- -------------------- ----------
1 John 1
Scott 2 1
3 Mike 2SQL >
Keep in mind index THAT MATERIALIZE is undocumented.
SY.
-
Get the types of columns in a select statement
Hello
Is there a way to get the types of columns that results in a select statement?
For example to force an analysis on this topic and then look for the types of columns resulting in the view v$?
Best regards
Klaus Mogensen
declare c number; d number; col_cnt integer; rec_tab dbms_sql.desc_tab; col_num number; begin c := dbms_sql.open_cursor; dbms_sql.parse(c, 'select dummy, 33 x, sysdate now from dual', dbms_sql.native); dbms_sql.describe_columns(c, col_cnt, rec_tab); col_num := rec_tab.first; while col_num is not null loop dbms_output.put_line( rec_tab(col_num).col_name || ' ' || case rec_tab(col_num).col_type when 1 then 'varchar2' when 2 then 'number' when 12 then 'date' else '???? ' || rec_tab(col_num).col_type end ); col_num := rec_tab.next(col_num); end loop; dbms_sql.close_cursor(c); end; / DUMMY varchar2 X number NOW date
-
Not finding the correct syntax for the select statement
Hello
The following statement works very well and gives the expected results:
As an academic exercise, I wanted to rewrite the above statement without using the WITH clause, I tried this (amongst dozens of other tests - I hit a mental block and cannot understand):prompt prompt Using WITH t prompt with t as ( select a.proj_id, a.proj_start, a.proj_end, case when ( select min(a.proj_start) from v b where (a.proj_start = b.proj_end) and (a.proj_id != b.proj_id) ) is not null then 0 else 1 end as flag from v a order by a.proj_start ) select proj_id, proj_start, proj_end, flag, -- -- the following select statement is what I am having a hard time -- "duplicating" without using the WITH clause -- ( select sum(t2.flag) from t t2 where t2.proj_end <= t.proj_end ) s from t;
Thanks for the help, much appreciated.prompt prompt without with prompt select c.proj_id, c.proj_start, c.proj_end, c.flag, -- -- This is what I've tried as the equivalent statement but, it is -- syntactically incorrect. What's the correct syntax for what this -- statement is intended ? -- ( select sum(t2.flag) from c t2 where t2.proj_end <= c.proj_end ) as proj_grp from ( select a.proj_id, a.proj_start, a.proj_end, case when ( select min(a.proj_start) from v b where (a.proj_start = b.proj_end) and (a.proj_id != b.proj_id) ) is not null then 0 else 1 end as flag from v a order by a.proj_start ) c;
John.
PS: The DDL for table v used by the above statements is:
drop table v; create table v ( proj_id number, proj_start date, proj_end date ); insert into v values ( 1, to_date('01-JAN-2005', 'dd-mon-yyyy'), to_date('02-JAN-2005', 'dd-mon-yyyy')); insert into v values ( 2, to_date('02-JAN-2005', 'dd-mon-yyyy'), to_date('03-JAN-2005', 'dd-mon-yyyy')); insert into v values ( 3, to_date('03-JAN-2005', 'dd-mon-yyyy'), to_date('04-JAN-2005', 'dd-mon-yyyy')); insert into v values ( 4, to_date('04-JAN-2005', 'dd-mon-yyyy'), to_date('05-JAN-2005', 'dd-mon-yyyy')); insert into v values ( 5, to_date('06-JAN-2005', 'dd-mon-yyyy'), to_date('07-JAN-2005', 'dd-mon-yyyy')); insert into v values ( 6, to_date('16-JAN-2005', 'dd-mon-yyyy'), to_date('17-JAN-2005', 'dd-mon-yyyy')); insert into v values ( 7, to_date('17-JAN-2005', 'dd-mon-yyyy'), to_date('18-JAN-2005', 'dd-mon-yyyy')); insert into v values ( 8, to_date('18-JAN-2005', 'dd-mon-yyyy'), to_date('19-JAN-2005', 'dd-mon-yyyy')); insert into v values ( 9, to_date('19-JAN-2005', 'dd-mon-yyyy'), to_date('20-JAN-2005', 'dd-mon-yyyy')); insert into v values (10, to_date('21-JAN-2005', 'dd-mon-yyyy'), to_date('22-JAN-2005', 'dd-mon-yyyy')); insert into v values (11, to_date('26-JAN-2005', 'dd-mon-yyyy'), to_date('27-JAN-2005', 'dd-mon-yyyy')); insert into v values (12, to_date('27-JAN-2005', 'dd-mon-yyyy'), to_date('28-JAN-2005', 'dd-mon-yyyy')); insert into v values (13, to_date('28-JAN-2005', 'dd-mon-yyyy'), to_date('29-JAN-2005', 'dd-mon-yyyy')); insert into v values (14, to_date('29-JAN-2005', 'dd-mon-yyyy'), to_date('30-JAN-2005', 'dd-mon-yyyy'));
select c.proj_id, c.proj_start, c.proj_end, c.flag, -- -- This is what I've tried as the equivalent statement but, it is -- syntactically incorrect. What's the correct syntax for what this -- statement is intended ? -- ( select sum(t2.flag) from (select a.proj_id, a.proj_start, a.proj_end, case when ( select min(a.proj_start) from v b where (a.proj_start = b.proj_end) and (a.proj_id != b.proj_id) ) is not null then 0 else 1 end as flag from v a order by a.proj_start ) t2 where t2.proj_end <= c.proj_end ) as proj_grp from ( select a.proj_id, a.proj_start, a.proj_end, case when ( select min(a.proj_start) from v b where (a.proj_start = b.proj_end) and (a.proj_id != b.proj_id) ) is not null then 0 else 1 end as flag from v a order by a.proj_start ) c;
-
mixture of column type in the select statement
Oracle 11g r2.
tab_test (name varchar2, blob... photo)
(1) select general use *.
Stored procedure: open ref_cursor to some * of table_test...
Coast of java: call.registerOutParameter (1, OracleTypes.CURSOR); Call.Execute ();
It works very well.
(2) enter the name of the column in the select such as
Stored procedure: open ref_cursor to select name, photo table_test...
Coast of java: call.registerOutParameter (1, OracleTypes.CURSOR); Call.Execute ();
ERROR: java.sql.SQLSyntaxErrorException: ORA-00932: inconsistent data types: expected - got BLOB
My question, if I specify the column names in the select statement, including the varchar2 and blob, how can I registerOutParameter (1, OracleTypes.CURSOR);?
Thank you
Scott
PS The number of returned columns, in real case schenario, is a little, so I prefer to specify column names.
Wrong forum. This forum is for questions of sql and pl/sql.
Enter the question ANSWER and the repost in the JDBC forum
When repost you provide the necessary information to help you:
1. information on the full version for Oracle DB
2 version of the JDK
3. the name and version of the JDBC jar file
4. real code that demonstrates the problem
You should also review the info re REF CURSOR in the JDBC Developer's Guide
http://docs.Oracle.com/CD/E16655_01/Java.121/e17657/oraint.htm#i1058743
-
I need to convert PDF to Excel, however, the columns and tabs make many merged cells and the number of columns empty. In addition to not separate the columns properly, I see many not separate lines together in the same cell. I even think that Adobe Acrobat Pro DC has limits. There is no way to set what points in columns to force the column break? Or create several columns that are unnecessary? How column in Excel, size fixed when import us text and define where breaks have columns of text?
Google Tradutor para empresas:Google para appsTradutor sitesGlobal market Finder traducao Toolkit
Acts traducao Instantaneasobre o Google TradutorCelularComunidadePrivacidade e TermosAjudaEnviar comments
PDF does not contain columns, lines, formats, styles or other aspects of word processing or spreadsheet file formats.
This is because the PDF is decidedly not a file format of word processor or a spreadsheet or something 'like' one of these.
(see ISO 32000 for what PDF "is")
Which allows to optimize the export of the content of a page PDF is to start with that tag well formed PDF (ISO 14289-1, PDF/UA-1).
Without that export is what it is and we performs the cleanup of any necessary content using the native application for the export of files (MS Word or Excel).
Be well...
Maybe you are looking for
-
Can I restore without losing data?
I don't have my Iphone saved on my computer. I need to get out of a boot loop, but I can't update. Is it possible to restore without losing any of my photos, music, etc.?
-
Setup of Windows Server 2012 cannot find a place to store temporary files
I am trying to upgrade Windows 2008 R2 DataCenter Windows Datacenter of 2012 I use the image en_windows_server_2012_x64_dvd_915478.iso - unpacked on C:\ or engraved on DVD DVD - upgrade is not allowed and I am referred to operation of installation of
-
Windows 7 is hung up on the Welcome screen after deferred journal
My problem is similar to what in the http://answers.microsoft.com/en-us/windows/forum/windows_7-performance/windows-7-hangs-up-at-the-welcome-screen/144a1b42-3b5d-4cf0-b66f-d6c063768b44 except when I connect normally, it does not occur. It is only i
-
Internet Explorer icon in the taskbar
I have a HP Pavilion P7-1017E model. We have faced a problem with the Internet Explorer icon in the taskbar background. You can see the little icon with free access to the internet, but we can't get the icon to enlarge the size full screen. (Norma
-
Not to install Adobe Reader DC
I can't install Adobe Reader DC on a computer Windows 10. Installation stops at about 60% of the way and request one a CD from IX Adobe. I do not have a CD. What should I do?