Select a random entry in the column
I have a column with the random number of digital inputs. What happens if I want to select a random number in this column. as they select a random number for the lottery. What is the code behind the button using forms6i?Don't know if you need something like this?
create table test_table
(
col number
);
begin
for i in 1..1000 loop
insert into test_table values (round(dbms_random.value(1001, 100000000)));
end loop;
commit;
end;
with data as
(
select col, row_number() over (order by col) rn
from test_table
),
lucky_num as
(
select round(dbms_random.value(1, (select max(rn) from data))) l from dual
)
select col, l lucky_num
from data, lucky_num
where rn = l;
COL LUCKY_NUM
---------------------- ----------------------
21711712 219
Tags: Database
Similar Questions
-
By selecting only normal characters of the column data
Hello
We have a table column that stores the names of party and this could be in non-English characters. If anyone knows how just to select the regular lines of English character of the table using a select query and does not include rows that have non-English characters?
Thank youryansun wrote:
Thank you Frank and Chris,Group names can have numbers, parentheses, commas (mostly address is attached). I wanted to so all English characters. Whatever in another language can be eliminated. I think in your examples, it considers that the alphabets.
So spaces, punctuation, numbers and symbols like '%' is all right; is this fair?
In this case:
SELECT * FROM table_x WHERE CONVERT ( party_name , 'US7ASCII' ) = party_name OR party_name IS NULL -- If wanted ;
-
I can't do allows me to select the address of the address list and fill in the To: field.
When you import anything in most applications, there is a screen where you move the data to match the new forms that will allow you to fill out. Thunderbird has a at the beginning of the import job. You may have missed on that one. At least you know how to solve this problem.
-
How to set the content of the column for lines of automatic separation
Hello guys,.
I have a problem with the column width and the content of column in a standard report. In the report are hugh entries that are not interrupted by a space character. I put my column width to a special value by usingen "style css: display block; Width: 300px; ». Now the problem is that some of the entries in the column with a longer width that the column width is set. Then they overlock the entries in the column next to them.
My question is: How to set the column lines of automatic content break after a certain number of characters?
After searching for a couple of websites and discussion thread, I found maybe a reference to the solution. I hope that it helps you to give me an answer.
A4 FORMAT LAST_NAME COLUMN
*/*
concerning
wderrWderr,
It is more a matter of HTML as a matter of APEX... You can start by looking here:
http://www.456bereastreet.com/archive/200704/how_to_prevent_html_tables_from_becoming_too_wide/Kind regards
DanBlog: http://DanielMcGhan.us/
Work: http://SkillBuilders.com/ -
The text of the e-mail under the column of the object does not match the selection
When I get to my Inbox and select an e-mail to open the middle box and the text box below do not match the selection in the object column. This has occurred recently and only on my laptop. My office works fine. The central area and the text matching, this email has been deleted but the text won't just change and go. I'm going on a trip tomorrow, and if I can't fix this, I won't be able to open emails with possible solutions. I'll see answers but can't open them.
right click on the folder, select Properties, and then on the button repair.
-
I just loaded all my music from my Windows XP system on my Windows 7 system. Each album has album art that appears in "now playing". But when I opened an album in library view and list titles, album art is not displayed even if she is among the columns selected to be shown. All other columns appear and disappear depending on whether I choose them, but the album art is not.
How to display album art? Please don't tell me to switch to playback. It is very unpleasant for me. Even if the album art is displayed there, the space that is takes 2/3 of the screen to keep a small image of the cover of the album. The list of receives securities only 1/3 remaining, so there is not enough space to display more than the name of the track, rating and length. In addition, I don't want to see the sides, but they show that even though I have deselected this column.
Windows 7 SP1 running Windows Media Player 12.0.7601.18741.
HI - in the library WMP view did you check the setting on the box highlighted in yellow in the screenshot below? (Depending on which section you are in you need to 'extended tile' or 'icons')-R.
-
SELECT which returns the columns as DESCRIBED?
Hello
I need a SQL that returns the column name and type as DESCRIBED in SQL * more.
I know that I can query all_tab_columns, but then I concatenate the string type myself.
SELECT column_name "Name" ,CASE WHEN data_type IN ('VARCHAR2','CHAR') THEN data_type||'('||data_length||')' WHEN data_type = 'FLOAT' THEN data_type||'('||data_precision||')' WHEN data_type = 'NUMBER' THEN CASE WHEN data_precision IS NULL THEN data_type WHEN data_scale = 0 THEN data_type||'('||data_precision||')' ELSE data_type||'('||data_precision||','||data_scale||')' END ELSE data_type END "Type" FROM all_tab_columns WHERE table_name = 'ABC' ORDER BY column_id;
An idea for another solution that considers each default data type?
Concerning
Marcus
Tip: you can run a trace and see what SQL query rained questions on your account when you issue a describe statement.
That said, I do not know if all the of that formatting is in the request or if it is made by the executable SQL more himself.
-
Need help with the analytical function select maximum and minimum of the results of the column
Hey there OTN.
I have an interesting application that I was hoping you would be able to help me with. I have a requirement to conditionally select the max and min of a column in bi-editor and since my editor works from an OBIEE analysis, I need store MAX and MIN of the column values in separate columns to match with. See the example below. You will notice that there are 4 stores including today's sales. I must have OBIEE through all the results of the column for sales, then choose the max of the dataset object. I can't use MAX here because he will choose the MAX of the line which will return only sales of this line. Instead, one must analyze all sales results and choose the appropriate column. Any idea on how to do this in OBIEE/publisher? Or is this not possible.
Day Store Sales Sales of MAX Sales MIN 05/11/15 Store 1 5000 8000 1000 05/11/15 Store 2 7500 8000 1000 05/11/15 Store 3 1000 8000 1000 05/11/15 Store 4 8000 8000 1000 I'm waiting for your answers. Thanks in advance!
PS: I will always mark messages that are useful and eventually mark it as correct answer if we come to a resolution!
See you soon.
You can't do the same thing with RANK ("dirty")?
Rank ("dirty") = 1: the max value in the result of sales
RANK (-1 * "Sales") = 1: the min in the result of sales value
I guess you can and then format the cells based on these values, where a value of 1 is the max or min according to the RANKING formula you used...
-
Alphabetical order of the entries in a column of textfield
How do alphabetize you entries in a column on a form?
You should find the forum for any product it is and post your questions there.
Here is a link to a page that provides links to all of the Adobe forums...
The Forum links page: https://forums.adobe.com/welcome
-
Select the column name when the value = something
Is there a way to select the column name when there is a specific value in it?
As follows:
create table (abc123)
COLUMN1 VARCHAR2 (50).
COLUMN2 VARCHAR2 (50).
Column3 varchar2 (50)
);
insert into abc123 values ('yes', 'Yes', 'No');
insert into abc123 values ('no', 'Yes', 'No');
INSERT INTO ABC123 VALUES ('no ',' no', 'No');
insert into abc123 values ('yes', 'Yes', 'Yes');
SELECT CASE WHEN COLUMN1 = 'Yes' THEN - the name of the column would be here somehow?
WHEN COLUMN2 = 'Yes' THEN - the name of the column would be here somehow?
WHERE Column3 = 'Yes' THEN - the name of the column would be here somehow?
Another null
finish as abc123 columnname
final results for the just Column1 would be:
COLUMN1
NULL VALUE
NULL VALUE
COLUMN1
I'm not sure what I use to get the name of column in there
Thank you.
Hello
708631 wrote:
Is there a way to select the column name when there is a specific value in it?
As follows:
create table (abc123)
COLUMN1 VARCHAR2 (50).
COLUMN2 VARCHAR2 (50).
Column3 varchar2 (50)
);
insert into abc123 values ('yes', 'Yes', 'No');
insert into abc123 values ('no', 'Yes', 'No');
INSERT INTO ABC123 VALUES ('no ',' no', 'No');
insert into abc123 values ('yes', 'Yes', 'Yes');
SELECT CASE WHEN COLUMN1 = 'Yes' THEN - the name of the column would be here somehow?
WHEN COLUMN2 = 'Yes' THEN - the name of the column would be here somehow?
WHERE Column3 = 'Yes' THEN - the name of the column would be here somehow?
Another null
finish as abc123 columnname
final results for the just Column1 would be:
COLUMN1
NULL VALUE
NULL VALUE
COLUMN1
I'm not sure what I use to get the name of column in there
Thank you.
Thanks for posting the CREATE TABLE and INSERT for the sample data.
Don't forget to post the exact results you want from these sample data. If the results depend on the parameters you want to pass a run time, then give a few different examples, with the the desired results of each.
You can hardcode the values you want, such as the column names in a query. For example:
SELECT CASE WHEN column1 = 'Yes' THEN 'Column1' END like y1
CASE WHEN column2 = 'Yes' THEN 'Column2' END like y2
CASE WHEN Column3 = 'Yes' THEN 'Column2' END like y3
, a. *-If wanted
Of abc123 one
;
-
Can I use * and the list of the column names in a select query
PLSQL again. Can I use * and the list of the column names in a select query, i.e. Select *, col1, col2 from Mytable. When I do that my questions tend to the bomb. Can do in other databases.
Thank you
Mike
Hi, Mike,.
If there is something else in the more SELECT clause *, then * must be qualified with a table name or alias.
For example:
SELECT Mytable. *, col1, col2
FROM MyTable;
-
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.
-
place a select query calculation in a different column in the same table
How can I put my calculation result in a column named within the same table?
I have a table called: dgpercentagedatachart
I use the columns of this dgpercentagedatachart: totalcecrating divided by lowestfeederrating times 100 to get the percentage
In the query, I gave the result the Alias of the cal
What I want is to put this result in my application or my calculation (in percentage) in my column "percent" on my table of dgpercentagedatachart vacuum.
How can I configure this syntax?
This is the select query, I came with:
Select dgpercentagedatachart.totalcecrating, dgpercentagedatachart.lowestfeederrating,.
100.00*dgpercentagedatachart.totalcecrating/dgpercentagedatachart.lowestfeederrating as cal
of dgpercentagedatachart;
Here are the results:
CAL lowestfeederrating Totalcecrating
8,978 7.48166666666666666666666666666666666667 120
30.951 25.7925 120
5.04 120 4.2
Hello
2685870 wrote:
How can I put my calculation result in a column named within the same table?
I have a table called: dgpercentagedatachart
I use the columns of this dgpercentagedatachart: totalcecrating divided by lowestfeederrating times 100 to get the percentage
In the query, I gave the result the Alias of the cal
What I want is to put this result in my application or my calculation (in percentage) in my empty column '%' on my table of dgpercentagedatachart .
How can I configure this syntax?
This is the select query, I came with:
Select dgpercentagedatachart.totalcecrating, dgpercentagedatachart.lowestfeederrating,.
100.00*dgpercentagedatachart.totalcecrating/dgpercentagedatachart.lowestfeederrating as cal
of dgpercentagedatachart;
Here are the results:
CAL lowestfeederrating Totalcecrating
8,978 7.48166666666666666666666666666666666667 120
30.951 25.7925 120
5.04 120 4.2
To change an existing column in a table, you can use the UPDATE or MERGE, instructions like this:
UPDATE dgpercentagedatachart
Percentage of VALUE = 100,00 * totalcecrating
/ lowestfeederrating
;
Noramlly, tables is not redundant columns like this. If percent can always be calculated from other columns, then it is probably better to calculate at run time and store it in the database, where you will have to be updated each time the columns it depends on change. You can use a view to avoid having to encode them the calculation.
If you really don't want a column that can be calculated in the same lines other columns, then use a virtual column (if you use Oracle 11 or higher).
I hope that answers your question.
If this isn't the case, please post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and also publish outcomes from these data.
If you ask on a DML statement, such as UPDATE, the sample data will be the content of the or the tables before the DML, and the results will be the State of the or the tables changed when it's all over.
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: Re: 2. How can I ask a question on the forums?
-
Select the column in a table that is defined in the select previous in the statement
Hello
I want to write a procedure that selects all the data in a table has then records them in the text file. I tested on table hr.countries.
My code is like this:
echo off newpage 0 space 0 pagesize 0 feed head off trimspool check out serveroutput on the value
coil countries.txt
define dtable = COUNTRY;
declare
col_num NUMBER;
no_lig NUMBER;
line VARCHAR2 (100);
Col VARCHAR2 (100);
Start
Select count (COLUMN_ID) in the col_num USER_TAB_COLUMNS WHERE table_name = '& dtable';
Select count (*) in no_lig of & dtable;
because me in 1.row_num
loop
1.col_num j
loop
Select column_name from col FROM USER_TAB_COLUMNS WHERE table_name = '& dtable' and column_id = j;
Select the pass in the row (select col, rownum: nurse of (select col from & dtable)) where rn = i;
IF (j! = col_num) THEN
DBMS_OUTPUT. PUT(Row ||) ', ');
ON THE OTHER
DBMS_OUTPUT. PUT (Row);
END IF;
end loop;
DBMS_OUTPUT. NEW_LINE;
end loop;
end;
/
spool off
I have had no error, but the result is like this:
COUNTRY_ID, COUNTRY_NAME, REGION_ID
COUNTRY_ID, COUNTRY_NAME, REGION_ID
COUNTRY_ID, COUNTRY_NAME, REGION_ID
.. and so on for the whole table.
I want to have results with data not only the names of columns. No idea what is the problem? I thought that select col online would do the thing, but the line is identical to the col variable...
Thank you
Honza
Set serveroutput on;
define dtable = COUNTRY;
declare
col_num NUMBER;
no_lig NUMBER;
line VARCHAR2 (100);
Col VARCHAR2 (100);
Start
Select count (COLUMN_ID) in the col_num USER_TAB_COLUMNS WHERE table_name = '& dtable;
Select count (*) in the no_lig argument of &dtable;
because me in 1.row_num
loop
1.col_num j
loop
Select column_name from col FROM USER_TAB_COLUMNS WHERE table_name = '& dtable' and column_id = j;
run immediately 'select'. Col | "from (select ' |) Col |', rownum: nurse from (select ' |) Col |' of & dtable)) where rn =' | I have
Online;
IF (j! = col_num) THEN
DBMS_OUTPUT. PUT(Row ||) ', ');
ON THE OTHER
DBMS_OUTPUT. PUT (Row);
END IF;
end loop;
DBMS_OUTPUT. NEW_LINE;
end loop;
end;
/
Output
anonymous block filled
AR, Argentina, 2
To, Australia, 3
BEING, Belgium, 1
BR, Brazil, 2
CA, Canada, 2
CH, Switzerland, 1
CN, China, 3
OF (Germany), 1
DK, Denmark, 1
For example, Egypt, 4
FR, France, 1
HE, Israel, 4
IN, India, 3
IT, Italy, 1
JP, Japan, 3
KW, Kuwait, 4
ML, Malaysia, 3
MX, Mexico, 2
NG, Nigeria, 4
NL, Netherlands, 1
SG, Singapore, 3
UK, United Kingdom, 1
WE, United States of America, 2
ZM Zambia, 4
ZW, Zimbabwe, 4
-
Error when selecting all the columns in the table
Hi all
When I write a query by selecting all the columns of the table fromo using * function as well as another new column, I get the error,
Select *, to_char (hiredate, 'fmday') day
WCP
where to_char (hiredate, 'fmday') ('Monday');
ERROR on line 1:
ORA-00923: THE KEYWORD not found where expected
I need all the columns in the table with the column user-defined 'day '. Is there a way I can get the result like this?
Hello
padders wrote:
Alias table to use...
Or the name of the table, for example
Select emp.*, to_char (hiredate, "fmday") as day
WCP
where to_char (hiredate, 'fmday') ('Monday');
The bottom line is that * must be qualified (with a table name or alias) when the SELECT clause includes anything else besides *.
Maybe you are looking for
-
How can I clean my Cache profiles Local file?
I have very few things in my Inbox, Archives, drafts and sent boxes - some MB - but the profile is 97 MB. How can I clean the profile - get rid of the useless things - while it is much smaller in size? If I delete the profile, it will regenerate?Well
-
HP 2 600: Cannot install windows 7 on 600 new G2
HelloI then try to upgrade the operating system windows 7, works the keyboard and mouse. UEFI, the keyboard and mouse work. The facility produced from a flash drive. Space screenshot below error. Please tell me, what to do in the UEFI?
-
Hi, please help me. He has written on my laptop which enter the administrator password or power on password, after that 3 passwords wrong it was written the system off and there were numbers 67633154, which password I can't write?
-
Cannot start Realplayer because MSVCP90.dll not found.
I can't install Realplayer SP because "the application failed to start because MSVCP90.dll not found. Reinstalling the application may fix this problem. I tried to re - install Realplayer, but the same problem occurs. Shortcuts to office etc. all app
-
I would like to know how can I save all the information that I added the MP over the years. information, I mean: ratings I gave titles, authors of lyrics that I added, albums, etc.