To generate the sequence in the select clause of the inner query
Hi all
Have the table and the data as below,
I want to generate a sequence number for all the distinct combinations of emp_id and emp_name running
DROP TABLE emp1.
CREATE TABLE emp1 (emp_id NUMBER, emp_name VARCHAR2 (100));
INSERT INTO emp1 VALUES (1, 'Name1');
INSERT INTO emp1 VALUES (2, 'Name2');
INSERT INTO emp1 VALUES (1, 'Name3');
INSERT INTO emp1 VALUES (2, 'Conjoint4');
COMMIT;
Output must be same as below:
EMP_ID | EMP_NAME | Reference ID |
1 | Name1 | 1000 |
1 | Name1 | 1000 |
1 | Name3 | 1001 |
2 | Name4 | 1002 |
2 | Name2 | 1003 |
"You cannot invoke CURRVAL and NEXTVAL in the subquery to CREATE."
"MATERIALIZED VIEW, or a SELECT, UPDATE, or DELETE statement;
Steve O'Hearn, Guide to preparing Oracle 1Z0-047
------
Tags: Database
Similar Questions
-
Hello!
I challenged the following problem. Here's the simple query:
SELECT id, id, id from
(select 1, sys_guid () as double id)
as you can see there is a sys_guid() function in the inner query. So, why do we use these
constructions? Right - to calculate the value of a function once and use it again so much
time, that we need. So I guess to get three identical fields. But, as it turns out, it is not
always too! I mean, on one version of Oracle database this query return the same three
fields, but on another - three different! Based on what the sys_guid() function is a kind of
random function, I can assume that the function is run three times in the second case
instead of one (as it should)! So why is it? Is - this bug from version, or an option in
control file that influence the optimizer?
PS: I found a workaround on this basis, where this query produces abnormal results, we can use
Internal ORDER BY clause in the query:
SELECT id, id, id from
(select 1, sys_guid () as command id double by 1)The oracle optimizer is the fusion view inline with the outer select block. He replaced effectively by:
select sys_guid(), sys_guid(), sys_guid() from dual
You can avoid this as follows:
select /*+ no_merge(x) */ id,id,id from (select 1,sys_guid() as id from dual) x
Published by: Toon Koppelaars on July 9, 2009 09:22
-
Cannot generate the dynamic query - ora-06502
Hi friends,
during execution of code below I get the error message: ora-06502 pl/sql numeric or value error on line 11
I'm not able to open a SQL session table logging.
DECLARE
T_Participants TYPE TABLE IS NUMBER;
c_Participant_Id t_Participants: = t_Participants();
CLOB V_SQL;
BEGIN
Select the participantid COLLECT in BULK IN c_Participant_Id in t_roster_detail
where rosterid = 10654
and ba = "MD";
I'm IN 1.c_Participant_Id.COUNT LOOP
V_SQL: = V_SQL | "SELECT p.participantid,.
Decode (p.Participantid, ' | c_Participant_Id (i) |', decode (p.Measureid, 10331, p.Current_Data, NULL), null) "10331_CURRENT."
Decode (p.Participantid, ' | c_Participant_Id (i) |', decode (p.Measureid, 10331, p.Goal_Data, NULL), null) "10331_Goal."
Decode (p.Participantid, ' | c_Participant_Id (i) |', decode (p.Measureid, 9640, p.Current_Data, NULL), null) "9640_CURRENT."
Decode (p.Participantid, ' | c_Participant_Id (i) |', decode (p.Measureid, 9640, p.Goal_Data, NULL), null) "9640_Goal."
Decode (p.Participantid, ' | c_Participant_Id (i) |', decode (p.Measureid, 9643, p.Current_Data, NULL), null) "9643_CURRENT."
Decode (p.Participantid, ' | c_Participant_Id (i) |', decode (p.Measureid, 9643, p.Goal_Data, NULL), null) "9643_Goal."
Decode (p.Participantid, ' | c_Participant_Id (i) |', decode (p.Measureid, 10332, p.Current_Data, NULL), null) "10332_CURRENT."
Decode (p.Participantid, ' | c_Participant_Id (i) |', decode (p.Measureid, 10332, p.Goal_Data, NULL), null) "10332_Goal."
Decode (p.Participantid, ' | c_Participant_Id (i) |', decode (p.Measureid, 10721, p.Current_Data, NULL), null) "10721_CURRENT."
Decode (p.Participantid, ' | c_Participant_Id (i) |', decode (p.Measureid, 10721, p.Goal_Data, NULL), null) "10721_Goal."
Decode (p.Participantid, ' | c_Participant_Id (i) |', decode (p.Measureid, 10701, p.Current_Data, NULL), null) "10701_CURRENT."
Decode (p.Participantid, ' | c_Participant_Id (i) |', decode (p.Measureid, 10701, p.Goal_Data, NULL), null) '10701_Goal '.
OF t_sce_msr_output_data p
WHERE IN (SELECT T_PC_AXIS_DEFINITION CREATES CREATES
WHERE PLANCOMPONENTID IN (SELECT PLANCOMPONENTID FROM T_PLAN_COMPONENT WHERE PLANID = 10702))
UNION ";
END LOOP;
DELETE FROM T_LOGGING_SQL;
INSERT INTO T_LOGGING_SQL VALUES (V_SQL);
COMMIT;
END;
SQL > desc t_sce_msr_output_data
Name Null? Type
----------------------------------------- -------- ------------
IDSCENARIO NOT NULL NUMBER
CREATES NOT NULL NUMBER
PARTICIPANTID NOT NULL NUMBER
NUMBER OF BASELINE_DATA
NUMBER OF CURRENT_DATA
NUMBER OF GOAL_DATA
You are way more complicate things here. First of all, there is no need at all for dynamic sql because the wy you are querying is incorect.
Even if you do not have an error, which you query will do is run the query on t_sce_msr_output_data once for each row returned by the cursor. Each iteration of the query will return all matching rows (i.e. lines for all the participantid in the t_sce_msr_output_data table), then the external decoding will be will force all other NULL columns for all the participantid that do not correspond to the "current" participantid
The query can be simplified to:
Select p.participantid,
Decode (p.Measureid, 10331, p.Current_Data, NULL) "10331_CURRENT."
Decode (p.Measureid, 10331, p.Goal_Data, NULL) "10331_Goal."
Decode (p.Measureid, 9640, p.Current_Data, NULL) "9640_CURRENT."
Decode (p.Measureid, 9640, p.Goal_Data, NULL) "9640_Goal."
Decode (p.Measureid, 9643, p.Current_Data, NULL) "9643_CURRENT."
Decode (p.Measureid, 9643, p.Goal_Data, NULL) "9643_Goal."
Decode (p.Measureid, 10332, p.Current_Data, NULL) "10332_CURRENT."
Decode (p.Measureid, 10332, p.Goal_Data, NULL) "10332_Goal."
Decode (p.Measureid, 10721, p.Current_Data, NULL) "10721_CURRENT."
Decode (p.Measureid, 10721, p.Goal_Data, NULL) "10721_Goal."
Decode (p.Measureid, 10701, p.Current_Data, NULL) "10701_CURRENT."
Decode (p.Measureid, 10701, p.Goal_Data, NULL) '10701_Goal '.
of t_sce_msr_output_data p
where in (select creates creates
of t_pc_axis_definition
where plancomponentid in (select plancomponentid
of t_plan_component
where planid = 10702)) and
participantid in (select participantid
of t_roster_detail
where rosterid = 10654 and
BA = "MD");
You probably want to pivot these results by participant, if so look in the note from the FAQ for the columns of the rows.
John
-
Performance problem - generating the SQL query
Hi experts,
We are facing a problem of performance on our dashboards. Used for testing dashboard page contains a prompt with two parameters (month & location) and 3 reports (1 table & 2 graphics). We put in the effort to optimize the speed of the query and the database returns the results after 1 sec. However, after changing values prompt, it takes up to 15 years before the request is sent to the database (based on the log).
We have done the following tests for an overview. Have tests in a test environment with clustered servers to exclude the possible implications of users numbers.
(1) raise the reports with the same prompt values
-> Page is returned immediately and the log shows that the results are retrieved from the cache
(2) run the page even with fewer reports
-> Removing a report from the page reduces the time to send the request to the database to 8 s
(3) check the traffic of a browser with sniffer
-> No. requests were sent 15-year timespan. Once the request is sent results instantly appear and the page is built in no time.
Can anyone provide an idea as to what happens between the time the user's request is triggered via the guest of dashboard and the request is sent to the database?Hi Karl,
I'm so glad you have at the bottom of it. You might find that oracle can help you with more information about the ODBC via a SR statement. -
Subselect query returns "invalid identifier", but the nested query return lines
I don't think it's a general SQL question.
Select * from persons where person_id in)
Select person_id with people whose name = 'Obama' - subquery
) and age > 18;
When I run the subquery, I get:
ORA-00904: "PERSON_ID": invalid identifier
00904, 00000 - '% s: invalid identifier '.
* Cause:
* Action:
Error on line: column 5: 8
This is because the table people do not have the person_id field.
But when I run the nested together query it returns all the lines in people with the AGE greater than 18.
How is he succeeds when the subquery is obviously wrong?
363f652b-263D-4418-933F-74a1d0a41b4c wrote:
I don't think it's a general SQL question.
Select * from persons where person_id in)
Select person_id with people whose name = 'Obama' - subquery
) and age > 18;
When I run the subquery, I get:
ORA-00904: "PERSON_ID": invalid identifier
00904, 00000 - '% s: invalid identifier '.
* Cause:
* Action:
Error on line: column 5: 8
This is because the table people do not have the person_id field.
But when I run the nested together query it returns all the lines in people with the AGE greater than 18.
How is he succeeds when the subquery is obviously wrong?
Yes - this is a general SQL question and ask often enough.
Correlated subqueries depend on the inner query, be able to see and access to the columns of the outer query. Normally see you referenced in the WHERE clause of the subquery and not in the SELECT clause, but the reference is valid in both places. This works because the columns of the tables in the main query are accessible in the subquery. "Person_id" is probably a column in the table 'people '.
Which can be a cause of problems 'odd' when the column (in your case "person_id") is more of a table.
Use an alias in the subquery in the subquery and you will find that it will not succeed.
See these two articles AskTom where he addresses this specific issue
http://asktom.Oracle.com/pls/Apex/f?p=100:11:0:P11_QUESTION_ID:3317493900346468494
http://asktom.Oracle.com/pls/Apex/f?p=100:11:0:P11_QUESTION_ID:155200640564
-
Select the table column group and generate a sequence number
I have to select data from a table column group and generate a sequence for every reset of the sequence from 1 to leave.
For example:
Data:
Col1 Col2 Col3 Col4
A NA KA-2009-08-13
B NA KA-2009-08-13
C NA KA-2009-08-13
A NA KA-2009-08-13
B NA KA-2009-08-13
A NA KA-2009-08-13
Expected results of the Select statement:
Col1 Col2 Col3 Col4 Seq_No
A NA KA-2009-08-13 1
A NA KA-2009-08-13 2
A NA KA-2009-08-13 3
B NA KA-2009-08-13 1
B NA KA-2009-08-13 2
C NA KA-2009-08-13 1
How can it be possible with a SELECT statement? Is it possible to assign the following numbers for a group of columns and put it back when it changes? In the above example, all columns are the key to generate the seq number
I know that this can be done using procedures stored and that is how I do it now by introducing a temporary table.
Can someone help me with this? Please let me know if the question is too vague to understand!
Thank you
NachiUse the row_number() analytics.
Ravi Kumar
-
Can any body help to get a script that can generate the sequence (length 3) with a combination of numbers and characters example: T11... TA1... TZ9... then on
With the help of the clause type
Select sqnc
from (select sqnc
from (select 'T00"sqnc, '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ' ordr
of the double
)
model
size of (0 I)
measures (sqnc, ordr, length (ordr) len)
rules iterate (1300) until (instr(sqnc[iteration_number],'~')! = 0)
(sqnc [iteration_number] = case when sqnc [cv (i) - 1] is null
then sqnc [0]
of another substr (sqnc [iteration_number - 1], 1, 1) |
-case when substr (sqnc [iteration_number - 1], 2, 1)<=>=>
so when business substr (sqnc [iteration_number - 1], 3, 1)<>
then substr (ordr [0], instr (ordr [0], substr (sqnc [iteration_number - 1], 2, 1)), 1)
of another nvl (substr (ordr [0], instr (ordr [0], substr (sqnc [iteration_number - 1], 2, 1)) + 1.1),'~ ')
end
end |
-case when substr (sqnc [iteration_number - 1], 3, 1)<>
then substr (ordr [0], instr (ordr [0], substr (sqnc [iteration_number - 1], 3, 1)) + 1.1)
else ' 0'
end
end
)
)
where instr(sqnc,'~') = 0
Concerning
Etbin
-
Insert/update of the XML help merge and to generate the sequence number
Hello
I'm working on Oracle 11 g.
I have a doubt with loading XML.
I get an xml and I need to insert or update data in a table. What I can accomplish by using the MERGE statement.
But there is a column in A table, I need to fill with a sequence number, based on the data sent in the xml file.
The XML does not send the data in this column.
And I have to make sure that sequence is created according to the order in which the records are present in xml.
For example the MERGER is insert five rows and update two lines and insert again 3 rows of xml in table A. The sequence number must be created in the same order for the column in the table.
Also for every new XML, the sequence starts with 1 and ends with the number of records in the xml file. I can't create a sequence and use the seq.nextval.
Please let me know, there is a way to achieve this.
Thank you!
Published by: 934451 on 8 August 2012 06:33
Published by: 934451 on 8 August 2012 06:50Hello
As a result of your previous thread: {: identifier of the thread = 2403469}
You can use the clause for ORDINALITE in XMLTable to generate the necessary sequence:
MERGE INTO target_table t USING ( SELECT x.seq_num, x.pk_id, x.col1, x.col2, ... FROM XMLTable( '/root/record' passing my_xml_doc columns seq_num FOR ORDINALITY , pk_id number path 'ID' , col1 varchar2(30) path 'COL1' , col2 varchar2(30) path 'COL2' , ... ) x ) src ON ( t.pk_id = src.pk_id ) WHEN MATCHED THEN UPDATE SET t.seq_num = src.seq_num , t.col1 = src.col1 , t.col2 = src.col2 , ... WHEN NOT MATCHED THEN INSERT (seq_num, pk_id, col1, col2, ...) VALUES (src.seq_num, src.pk_id, src.col1, src.col2, ...) ;
-
create table t (id int primary key, dt date, file_no int, batch_no int, data varchar2(5) ); insert into t values (1,trunc(sysdate),23,113,dbms_random.string('a',5)); -- 1.1.1 insert into t values (2,trunc(sysdate),23,345,dbms_random.string('a',5)); -- 1.2.1 insert into t values (3,trunc(sysdate),23,345,dbms_random.string('a',5)); -- 1.2.2 insert into t values (4,trunc(sysdate),23,543,dbms_random.string('a',5)); -- 1.3.1 insert into t values (5,trunc(sysdate),23,543,dbms_random.string('a',5)); -- 1.3.2 insert into t values (6,trunc(sysdate),23,543,dbms_random.string('a',5)); -- 1.3.3 -- insert into t values (7,trunc(sysdate),24,333,dbms_random.string('a',5)); -- 2.1.1 insert into t values (8,trunc(sysdate),24,333,dbms_random.string('a',5)); -- 2.1.2 insert into t values (9,trunc(sysdate),24,333,dbms_random.string('a',5)); -- 2.1.3 insert into t values (10,trunc(sysdate),24,222,dbms_random.string('a',5)); -- 2.2.1 insert into t values (11,trunc(sysdate),24,222,dbms_random.string('a',5)); -- 2.2.2 insert into t values (12,trunc(sysdate),24,111,dbms_random.string('a',5)); -- 2.3.1
Oracle 11.1
How can given this structure and data, I generate sequence at the end of each line numbers? Basically, the sequence number (x.y.z) is such that x (1.n) is awarded for each unique value in file_no. In each x, y (1.n) is assigned for each unique value of batch_no. Within each y, z (1.n) is assigned for all records of this batch. Sample data shows only dt but all sequences must reset and start over when dt changes.
I tried using row_number() over (partition by dt, file_no) and such but nothing quite gives me what I'm looking for.
Help? Thank you
Hello
HELEN wrote:
If you look at my CREATE TABLE, the ID column is a primary key and represents the order of the data in the file.
Done batch_no = 100 come before or after 101? Batch_no = 100 a ID so much until after the id for batch_no = 101.
Good point, but that won't happen because of the way the 'record' is generated. All batch_nos will be contiguous. So if batch_no 100 comes earlier in the file as 101, it should get some 2nd highest sequence number. Otherwise, lower. Basically, the 2nd part of the sequence must simialar logical number to the 3rd party (i.e. order by id) but that messes things. Still struggle with it. Any help appreciated.
I think I understand. You say that, because of the way that the ID is issued, it wouldn't matter if you used the highest id of the batch_no, or the lowest id, or the average, or if you chose one at random; you would get the correct order in all cases.
The following query uses the id low in the order file_no and batch_nos.
WITH got_min_ids AS
(
SELECT id, dt, file_no, batch_no, data
MIN (id) over (PARTITION BY dt
file_no
) AS min_id_file_no
MIN (id) over (PARTITION BY dt
file_no
batch_no
) AS min_id_batch_no
T
)
SELECT id, dt, file_no, batch_no, data
DENSE_RANK () OVER (PARTITION BY dt
ORDER BY min_id_file_no
)
|| '.'
|| DENSE_RANK () OVER (PARTITION BY dt
file_no
ORDER BY min_id_batch_no
)
|| '.'
|| ROW_NUMBER () OVER (PARTITION BY dt
file_no
batch_no
ORDER BY id
) AS seq
OF got_min_ids
ORDER BY dt, min_id_file_no, min_id_batch_no, id
;
The main request is in fact what I posted before, but instead of
"ORDER BY file_no" and "ORDER BY batch_no", she uses
"ORDER BY min_id_file_no" and "ORDER BY min_id_batch_no". These values are calculated in the subquery, got_min_ids.
Output (including the additional sample data I posted):
ID FILE_NO DT BATCH_NO SEQ DATA
---------- ----------- ---------- ---------- ----- ----------
1 23 25 April 2014 113 dXAad 1.1.1
2 345 23 25 April 2014 pumVG 1.2.1
3 345 23 25 April 2014 jLnbO 1.2.2
4 23 25 April 2014 543 xKhCL 1.3.1
5 23 25 April 2014 543 JQoWk 1.3.2
6 23 25 April 2014 543 YjJeC 1.3.3
7 24 25 April 2014 333 WjQNE 2.1.1
8 24 25 April 2014 333 ScWSL 2.1.2
9 24 25 April 2014 333 pXDSD 2.1.3
10 222 24 25 April 2014 OSajn 2.2.1
11 222 24 25 April 2014 QNpix 2.2.2
12 24 111 OwkjI 2.3.1 April 25, 2014
91 100 99 25 April 2014 sRWmT 3.1.1
93 100 99 25 April 2014 IAEFd 3.1.2
92 101 99 25 April odQxh 2014 3.2.1
I know you said that this situation is impossible (that is, if ID 91 and 93 have the same batch_no, then id 92 cannot have a different batch_no), but the application works even if this rule is broken.
-
How to generate the alphanumeric sequence under oracle
Hi Experts,
I need to create a primary key as below,
Its should start from a001, a002... a100 after reaching 100 the next value in the sequence must begin by b001... b100, like wise the sequence should go through until summer z001 alphabet... z100.
Please let me know for any information.
Kind regards
Millar
This will generate the a1 - a100, b1 - b100,... z1 - z100, aa1 - aa100, ab1 - ab100,... az1 - az100,...
SEQUENCE of s FALL
/
CREATE SEQUENCE s
/
CREATE OR REPLACE
FUNCTION get_s_nextval
RETURN VARCHAR2
IS
number of v_nextval;
number of v_alpha;
number of v_number;
v_base26 varchar2 (100);
BEGIN
v_nextval: = s.nextval;
v_number: = MOD(v_nextval,100) CASE
WHEN 0 THEN 100
Of OTHER MOD(v_nextval,100)
END;
v_alpha: = CEIL(v_nextval / 100) - 1;
v_base26: = NULL;
LOOP
v_base26: = CHR (ASCII ('a') + MOD(v_alpha,26)) | v_base26;
EXIT WHEN v_alpha<>
v_alpha: = TRUNC(v_alpha / 26) - 1;
END LOOP;
RETURN v_base26 | LPAD (v_number, 3, '0');
END;
/
WITH t AS)
SELECT s get_s_nextval,
level lvl
OF the double
CONNECT BY level<=>=>
)
SELECT s
T
WHERE MOD(lvl,100)<=>=>
ORDER BY lvl
/
S
------------------
A001
A100
B001
B100
C001
C100
D001
D100
E001
E100
F001S
------------------
F100
G001
G100
H001
H100
I001
i100
J001
J10020 selected lines.
SQL >
SY.
-
Generate the '@' character ascii with an ATL sequence on a T60p laptop?
Greetings,
I have a Lenovo T60p laptop. How to emulate a full 102 key keyboard when it comes to composing as ATL-64 sequences to generate the '@' character ascii. I read the documentation and did not.
Kind regards
Jean-Pierre
After you activate the number lock the box red is the num pad and the characters and numbers in the lower right corner of the surface of the key is activated.
If the "M" button is now a '0 '.
The zero on the left while typing in the ASCII code for the '@' is required for windows - so you ask Microsoft, but not me
-
Hello
Doc Oracle says the following on the identifiers in the SELECT in PL/SQL clause: there is no possibility of ambiguity in the SELECT clause because any identifier in the SELECT clause must be a database column name.
If we assume that only valid column identifier are allowed in the SELECT clause.
But I tried the following:
DECLARE toto NUMBER := 10; tata NUMBER := 0; BEGIN SELECT toto INTO tata FROM employees WHERE employee_id = 101; DBMS_OUTPUT.PUT_LINE(tata); END; /
And there is no error telling me that toto is not a column in the employees table and the result is the same as: toto: = aunt;
Won't the doc or did I just miss something?
Thanks for your response!
Hello
rep0ne wrote:
Hello
Doc Oracle says the following on the identifiers in the SELECT in PL/SQL clause: there is no possibility of ambiguity in the SELECT clause because any identifier in the SELECT clause must be a database column name.
If we assume that only valid column identifier are allowed in the SELECT clause.
Post a link to this Oracle doc.
But I tried the following:
- DECLARE
- Toto NUMBER: = 10;
- Auntie NUMBER: = 0;
- BEGIN
- SELECT toto IN Auntie FROM Employees WHERE employee_id = 101;
- DBMS_OUTPUT. Put_line (Auntie);
- END;
- /
And there is no error telling me that toto is not a column in the employees table and the result is the same as: toto: = aunt;
...
You're right that toto is an identifier, but this isn't a column name. (Of a subquery) column alias are not database of the names of columns either, nor are the names of the user-defined function.
Also, there is a possibility for ambiguity even if all the names are the database column names.
Won't the doc or did I just miss something?
I can't say until I see the doc you're talking about.
Oracle documentation is sometimes misleading and sometimes just plain wrong. For each mistake outright example that I saw in the docs of Oracle, there might be 20 cases where the meaning is unclear or misleading and maybe 200 where I just read it wrong.
-
Hello
First post! Woohoo!
Not sure why some of my sequences make this. I'll try to make that clear as possible, but try to put this in words could be confusing. Apologies in advance.
When Hi hit game the clip in the sequence is not selected (highlighted) and when I stop playing, it is selected (highlighted).
Why is this super frustrating?
I have markers in the sequence. (and I don't have or don't want markers on my clip).
I have my window open markers and I want to read/edit comments for my markers.
BUT when playback stops, the clip in the timeline panel is selected, then my window markers swaps to the source clip
and then I need to re - select the sequence for my markers window window display the details of the marker.
And worse still, sometimes when my sequence is selected (see my bearings in the markers window), when I click in the comments box to type in a description, me clicking on which comments on the box says actually the element in the sequence that is causing my markers window Exchange back to display the clip markers (once again - I don't not wishes to add markers of my clips I want only that they in the sequence).
And it's incompatible. Sometimes it works first try, sometimes it works 3rd test.
This is not the first time that I have worked in this way, and I don't remember this issue previously.
Side note: I use a multicam in mu sequence clip.
Any help would be greatly appreciated! I like dropping the interviews in this way and I really want to keep this workflow.
Thank you!
Disable
-
How to remove the name of the column in the select clause
Hello guys,.
I want to just delete a column name in the select clause. Because I don't want to write all the names of columns. I hope I am.
In other words, I want the following.
Select * - unwanted_column from table; instead of this Select col1, col2, col3, col4, ........ col 10000 from table;
Hello
There is nothing in SQL, which means "all columns * except *...» ». As others have said, the only way to achieve these results in SQL is to list all the columns you want.
Your front end may have a feature that allows you to hide a specific column. For example, in SQL * Plus, you can use COLUMN... NOPRINT , like this:
COLUMN dname NOPRINT SELECT * FROM scott.dept ORDER BY dname ;
Output:
` DEPTNO LOC ---------- ------------- 10 NEW YORK 40 BOSTON 20 DALLAS 30 CHICAGO
There is a column called dname in the scott.dept table; the query above uses actually. But, because of the order of the COLUMN, SQL * Plus will not display this column.
Published by: Frank Kulash on February 26, 2013 10:10
Example of scott.dept has changed. -
Decimal separator in the SELECT Clause
Hello
I have the following parameters of decimal number:
SQL > select value
2 from v$ nls_parameters
3 where parameter = "NLS_NUMERIC_CHARACTERS;
VALUE
----------------------------------------------------------------
,.
If I show a decimal number, I get a comma as decimal separator
SQL > select 10/100 double;
10/100
----------
1
But if I use a decimal separator in the SELECT clause, I get:
SQL > select 100 * 1.1 double;
100 * 1 1
---------- ----------
1 100
It does not work. But the use of a period as the decimal separator works:
SQL > select 1.1 * 100 double;
1.1 * 100
----------
110
Maybe it's something that I never had to deal with before, but I thought that the number format applied to results of sql, as well as the numbers you have used sql clauses.
Kind regards
Nestor BoscanHi, Nestor,
user594312 wrote:
... I thought that the number format applied to results of sql, as well as the numbers you have used sql clauses.No.; it applies to the results and it can affect implicit conversions, but it does not apply to the SQL code.
The period (or dot, '.') is the decimal separator in literals always digital. There is no way to change this.Think how confusing it would be if it applied to the SQL code. For example:
WHERE num_col IN (1,2)
We compare num_col values 1 or 2? He comes in, what happens if we wanted to do the opposite?
If you really want to use the comma as the decimal separator, you may have to use strings, not numbers, and it could be much less effective.
For example:SELECT 100 * TO_NUMBER ('1,1') -- This assumes your NLS settings are correct FROM dual;
Of course, the effectiveness will not be a problem when you select 1 row of double.
Maybe you are looking for
-
Where to go to find my messages please? See you soon
-
Slow internet speed because of the Marvell Yukon LAN driver
Hi all! I'm a newbie here so don't know if I'm supposed to ask this question here but anyway, hope, my problem is solved somehow. I'm on a Toshiba Satellite A200 laptop computer, I received last week and everything works well except my internet speed
-
Can I install XP on Equium A200?
Hello I have a laptop Equium A200-1v0 currently under Vista Home Premium, my question is... Can I install Windows XP Home Edition on the laptop?My only concern are drivers etc... Thank you
-
Folio 1040 G1: How to clear the bios password
I got a laptop HP 1040 Folio G1. A few years ago, I would set the password of the bios on this subject. (I have still remember and use PW daily) But now, I didn't need to protect more bios password. I tried to delete it, but I found that - to just ch
-
binning error of Hamamatsu orca-dsquared
Hello world! I use a camera hamamatsu ORCAD-dsquared and when I want to put a frolic binning 1 x 1 on it. I got this error: 'TMERR_UNKNOWNERROR to C:\Program NIUninstaller Instruments\LabVIEW video 2011\user.lib\Hamamatsu Capture\tm_setparameter.vi'