How to truncate my query results in a column to reflect only 2 decimal places
SELECT (COLUMNNAME/60) / 60 AS ACTHOURSFROM TABLENAME
This request is currently converting seconds to hours, but some values are endless beyond the comma. I want only the results to show 2 decimal places.
Can anyone suggest how to proceed?
SELECT round((COLUMNNAME/60)/60,2) AS ACTHOURS_ROUND,
trunc((COLUMNNAME/60)/60,2) AS ACTHOURS_CUT
FROM TABLENAME;
You can find the documentation here:
http://docs.Oracle.com/CD/E11882_01/server.112/e10592/functions155.htm#i78633
http://docs.Oracle.com/CD/E11882_01/server.112/e10592/functions221.htm#i79729
Published by: hm on 26.04.2012 05:20
Tags: Database
Similar Questions
-
Hello
with this sql:
SELECT c.country_name, l.city FROM countries c, locations l
I have 575 lines,
How can I truncate the output to 100 lines?
Add this predicate:
WHERE ROWNUM<=>=>
-
How to prioritize the query result using analytic functions
Hello
Published by: prakash on May 20, 2013 01:42Use ROW_NUMBER
SQL> select PRVDR_LCTN_X_SPCLTY_SID,PRVDR_LCTN_IID,PRVDR_TYPE_X_SPCLTY_SID,STATUS_CID 2 from 3 ( 4 select t.*, 5 row_number() over(partition by PRVDR_TYPE_X_SPCLTY_SID 6 order by STATUS_CID) rn 7 from your_table t 8 ) 9 where rn = 1; PRVDR_LCTN_X_SPCLTY_SID PRVDR_LCTN_IID PRVDR_TYPE_X_SPCLTY_SID STATUS_CID ----------------------- -------------- ----------------------- ---------- 75292110 10153920 75004770 1 75291888 10153920 75004884 2 75292112 10153920 75004916 1 75292117 10153920 75004974 1
-
attempts to display the query results in 2 columns
I'm trying to change someone elses existing of code to display the results of a query in 2 columns on a web page.
The result of the existing code can be seen
here
Here is the code I am trying to change
< table width = "95%" border = "0" align = "center" cellpadding = "4" cellspacing = "2" >
< cfoutput query = "News" StartRowOptional = "" #StartRow_News # "LignesMax =" #MaxRows_News #">"
< tr align = "center" class = "TEXTnormal" >
< class nowrap = "style1 TEXTnormal" td >... < table >
< /tr >
< class tr = "TEXTnormal" >
< td > < table width = "100%" border = "0" cellpadding = "0" cellspacing = "0" class = "TEXTnormal" >
< b >
< td > < cfif News.ImageNameThumb gt 0 >
"< a href =" news_view.cfm? recordID = #News.ID #"> < img src =" "uploadedimages / #News.ImageNameThumb #" alt = "#News.ImageCaption #" hspace = "8" hspace = "0" border = "0" align = "left" > < / has >
< cfelse >
< / cfif > < table >
< td > < a href = "" news_view.cfm? recordID = #News.ID # "class ="TEXThighlight"> #News.Title # < /a > - #News.Day #. #News.Month #. #News.Year # < br >"
#News.Summary # < table >
< /tr >
< / table > < table >
< /tr >
< / cfoutput >
< /table >
I changed the above code to
< table width = "95%" border = "0" align = "center" cellpadding = "4" cellspacing = "2" >
< cfset LoopEndRow = CEILING(#EndRow_News#/2) >
< cfloop
index = "row".
from = "#StartRow_News #
to = "#LoopEndRow #
step = "1" >
< class tr = "TEXTnormal" >
< cfset breaker = 0 >
< cfloop
index = "column".
from = '0 '.
to = '2 '.
step = "1" >
< cfoutput query = "News1" StartRowOptional = "" #StartRow_News # "LignesMax =" #MaxRows_News #">"
< td width = "50%" >
< table width = "100%" border = "0" cellpadding = "0" cellspacing = "0" class = "TEXTnormal" >
< b >
< td > < cfif News1.ImageNameThumb gt 0 >
"< a href =" news_view.cfm? recordID = #News1.ID #"> < img src =" "uploadedimages / #News1.ImageNameThumb #" alt = "#News1.ImageCaption #" hspace = "8" hspace = "0" border = "0" align = "left" > < / has >
< cfelse >
< / cfif > < table >
< td > < a href = "" news_view.cfm? recordID = #News1.ID # "class ="TEXThighlight"> #News1.Title # < /a > - #News1.Day #. #News1.Month #. #News1.Year # < br >"
#News1.Summary # < table >
< /tr >
< / table > < table >
< cfset breaker breaker + 1 = >
< cfif breaker EQUAL 2 >
< cfbreak >
< / cfif >
< / cfoutput >
< / cfloop >
< /tr >
< / cfloop >
< /table >
The results of this code change can be see here
as you can see what I did gives the number of columns (2)
and the correct number of lines for the amount of data (3)
However, each line shows the first 2 pieces of data returned by the query
Can I change the output query so that it returns the data SET by the amount of data already out items?
If so, how?
#data #.
closing tags -
How to leave only two decimal places in UsedSpaceGB value
Hello
I have the following statement:
Get - vm server * | SELECT name, UsedSpaceGB, VMhost, comments | FT-auto
but the usedspace Go is like this 104.06407394539564847946166992
How can I put it in 104,06?
With the Round function
get-vm server* | select name,@{N="UsedSpaceGB";E={[math]::Round($_.UsedSpaceGB,2)}},VMhost,guest | ft -auto
-
How to modify data in "Result grid query" in Oracle SQL developer
Dear,
I would like to know how to change values directly in the query result grid.
I use Oracle SQL Developer version 4.0.3.16
Thank you
Khalil
I checked in SQL Developer 4 and I found no option to do this.
I don't think it's available. You can open the table and add filters on each column and change. Or you can add where clause as suggested the link written by Jeff that I already gave. (http://www.thatjeffsmith.com/archive/2013/06/sql-developer-im-looking-at-a-record-how-do-i-edit-it/)
Or you write update instructions.
See you soon
AJ
-
How to transpose the query with the following result
Dear all,
Can someone tell me a method to convert my query result
Details are provided in
http://obiee11ge.blogspot.com/2010/07/how-to-transpose-query-with-following.html
Concerning
MustafaHello
Try this
Create a request combined with,criterion no. 1: model, revenue (Actual), Cogs (Actual), Opex (Actual), PL (Actual)
in the dummy column fx enter the "Real" value
criterion 2: model, revenue (Yago), Cogs (YAgo), Opex (Yago), PL (Yago)
in the dummy column fx enter the value as "Yago".
criterion 3: model, revenue (Budget), Cogs (Budget), Opex (Budget), PL (Budget)
in the dummy column fx enter the value as 'Budget '.
Now go to the columns of result and set names coumn (revenue, COGS, Opex, PL) for the result set.
For the Dumny, remove column header.In a sheet view, you will get the result.
Thank you
Vino -
How to get SQL Developer 4.1 to display the query result?
SQL DEV 4.0.3.16.84 execution of a SELECT statement is stored in a .sql file causes the window of the query result of pop-up indicating the result of a SELECT statement. SQL DEV 4.1 is not to do so.
Oops on my part; my SQL formatting has been the root cause. I got used to insert split without any character of comment lines in front of them. For example:
==================================================
Select funny business;
The foregoing indicates the behavior described.
--==================================================
Select funny business;
With the dash double comment shows, the SQL works very well.
This is different than previous versions of SQL Developer, but is probably better functionality. I'll try to mark it as answered, but anyone with the admin should certainly do so if I can't.
-
How to clear the search query result set
I dropped a search with the table query. When I search a value it is the display of the result, but when I click on the reset button, only the query Panel is reset to zero and not the table. What can I do to reset the table component associated with the query?When I click on the reset button, only the query panel goes to zero and no table.
It will be reset nt table.
What can I do to reset the table component
Use of the component range reset. to do so.
http://jobinesh.blogspot.in/2009/10/reset-content-of-Web-page.html
http://myadfnotebook.blogspot.in/2011/05/making-reset-button-in-afquery.html trickles you want
http://andrejusb.blogspot.in/2009/09/programmatical-reset-for-query-results.html-edited lately
Published by: ADF7 on February 22, 2012 12:58 AM
-
How to write output to a txt file query results
have a sub query resulting in some records I want to write in a txt file
Select employee a.empcode a, b the address where a.empcode! = b.emp.codeYou can use UTL_FILE to do so, either specifically for your query or more generically as below:
As user sys:
CREATE OR REPLACE DIRECTORY TEST_DIR AS '\tmp\myfiles' / GRANT READ, WRITE ON DIRECTORY TEST_DIR TO myuser /
As myuser:
CREATE OR REPLACE PROCEDURE run_query(p_sql IN VARCHAR2 ,p_dir IN VARCHAR2 ,p_header_file IN VARCHAR2 ,p_data_file IN VARCHAR2 := NULL) IS v_finaltxt VARCHAR2(4000); v_v_val VARCHAR2(4000); v_n_val NUMBER; v_d_val DATE; v_ret NUMBER; c NUMBER; d NUMBER; col_cnt INTEGER; f BOOLEAN; rec_tab DBMS_SQL.DESC_TAB; col_num NUMBER; v_fh UTL_FILE.FILE_TYPE; v_samefile BOOLEAN := (NVL(p_data_file,p_header_file) = p_header_file); BEGIN c := DBMS_SQL.OPEN_CURSOR; DBMS_SQL.PARSE(c, p_sql, DBMS_SQL.NATIVE); d := DBMS_SQL.EXECUTE(c); DBMS_SQL.DESCRIBE_COLUMNS(c, col_cnt, rec_tab); FOR j in 1..col_cnt LOOP CASE rec_tab(j).col_type WHEN 1 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000); WHEN 2 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_n_val); WHEN 12 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_d_val); ELSE DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000); END CASE; END LOOP; -- This part outputs the HEADER v_fh := UTL_FILE.FOPEN(upper(p_dir),p_header_file,'w',32767); FOR j in 1..col_cnt LOOP v_finaltxt := ltrim(v_finaltxt||','||lower(rec_tab(j).col_name),','); END LOOP; -- DBMS_OUTPUT.PUT_LINE(v_finaltxt); UTL_FILE.PUT_LINE(v_fh, v_finaltxt); IF NOT v_samefile THEN UTL_FILE.FCLOSE(v_fh); END IF; -- -- This part outputs the DATA IF NOT v_samefile THEN v_fh := UTL_FILE.FOPEN(upper(p_dir),p_data_file,'w',32767); END IF; LOOP v_ret := DBMS_SQL.FETCH_ROWS(c); EXIT WHEN v_ret = 0; v_finaltxt := NULL; FOR j in 1..col_cnt LOOP CASE rec_tab(j).col_type WHEN 1 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_v_val); v_finaltxt := ltrim(v_finaltxt||',"'||v_v_val||'"',','); WHEN 2 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_n_val); v_finaltxt := ltrim(v_finaltxt||','||v_n_val,','); WHEN 12 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_d_val); v_finaltxt := ltrim(v_finaltxt||','||to_char(v_d_val,'DD/MM/YYYY HH24:MI:SS'),','); ELSE v_finaltxt := ltrim(v_finaltxt||',"'||v_v_val||'"',','); END CASE; END LOOP; -- DBMS_OUTPUT.PUT_LINE(v_finaltxt); UTL_FILE.PUT_LINE(v_fh, v_finaltxt); END LOOP; UTL_FILE.FCLOSE(v_fh); DBMS_SQL.CLOSE_CURSOR(c); END;
This allows the header line and the data to write into files separate if necessary.
for example
SQL> exec run_query('select * from emp','TEST_DIR','output.txt'); PL/SQL procedure successfully completed.
Output.txt file contains:
empno,ename,job,mgr,hiredate,sal,comm,deptno 7369,"SMITH","CLERK",7902,17/12/1980 00:00:00,800,,20 7499,"ALLEN","SALESMAN",7698,20/02/1981 00:00:00,1600,300,30 7521,"WARD","SALESMAN",7698,22/02/1981 00:00:00,1250,500,30 7566,"JONES","MANAGER",7839,02/04/1981 00:00:00,2975,,20 7654,"MARTIN","SALESMAN",7698,28/09/1981 00:00:00,1250,1400,30 7698,"BLAKE","MANAGER",7839,01/05/1981 00:00:00,2850,,30 7782,"CLARK","MANAGER",7839,09/06/1981 00:00:00,2450,,10 7788,"SCOTT","ANALYST",7566,19/04/1987 00:00:00,3000,,20 7839,"KING","PRESIDENT",,17/11/1981 00:00:00,5000,,10 7844,"TURNER","SALESMAN",7698,08/09/1981 00:00:00,1500,0,30 7876,"ADAMS","CLERK",7788,23/05/1987 00:00:00,1100,,20 7900,"JAMES","CLERK",7698,03/12/1981 00:00:00,950,,30 7902,"FORD","ANALYST",7566,03/12/1981 00:00:00,3000,,20 7934,"MILLER","CLERK",7782,23/01/1982 00:00:00,1300,,10
The procedure allows for the header and the data to separate files if necessary. Just by specifying the file name "header" will put the header and the data in a single file.
Adapt to the exit of styles and different types of data are needed.
-
Hello friends
I created a table called newspaper as follows
create table log (number, login_date date logid);
Insert in the journal values(101,sysdate);
After 10 minutes, I created a slider as follows...
declare
uname varchar2 (30);
logdate date;
cursor name_c is
Select logid, login_date in the newspaper where logid = 101 and login_date = sysdate;
Start
Open name_c;
extract name_c in uname, logdate;
if(name_c%found) then
dbms_output.put_line ('FOUND');
end if;
close name_c;
end;
/
Set serveroutput on;
PL/SQL procedure successfully completed.
But I did get no results... I found the reason that when I insert in the sysdate table stores all fields
including hour, min, sec, etc... But I extract sysdate cursor [after 10 min] right now the fields change. Then only the cursor don't fetch no line... Please, help me to extraction of the row in the table of the newspaper...
How to truncate field sysdate to extract only date like('18-feb-2011')...Change the cursor like query
cursor name_c is select logid,login_date from log where logid=101 and trunc(login_date)=trunc(sysdate);
Edited by: Oracler February 17, 2011 22:48
Edited by: Oracler February 17, 2011 22:48
-
Query results pane should display the entire XML following the execution of the query
Hi, I'm trying to get the xml output results returned in sqldeveloper returned in full.
they are truncated to.
I tried the trick / * xml * / but that is implemented in the form xml cdata codes and other structures of nickname.
Select xmlserialize (DOCUMENT
XMLELEMENT ("root",
XMLAttributes ('http://www.millicom.com' as 'xmlns'),
XMLAGG)
XMLELEMENT ("line",
XMLFOREST (U.username,
U.user_id,
U.PASSWORD,
U.ACCOUNT_STATUS,
U.LOCK_DATE,
U.EXPIRY_DATE,
U.DEFAULT_TABLESPACE,
U.TEMPORARY_TABLESPACE,
U.CREATED,
U.PROFILE,
U.INITIAL_RSRC_CONSUMER_GROUP,
U.EXTERNAL_NAME,
U.PASSWORD_VERSIONS,
U.EDITIONS_ENABLED,
U.AUTHENTICATION_TYPE)))
AS CLOB DASH)
from dba_users U
CROSS JOIN (select 1 of the double connect by level < = 10);
Thanks for any help you can offer.
JM
Hi jm,
In the line of query results, did scroll all the way to the right, then click twice on the «...» "at the end of the line to open the cell editor?
So again, who does not show all the XML, it may be a problem with the version of the ojdb6.jar in use (11.2.0.3 client or later is required), or whether or not the JDBC OCI/thickness is used. Read the following discussion: retrieve XMLTYPE based on very slow saved schema
Kind regards
Gary
SQL development team
-
Help on the game of query results
Hi gurus,
Have this survey for my requirement of dataset sql.
Sample, it's that I have to pick up the nonfunctional currency transactions.
Lets say for a given month, data that are present are for CurrencyA and CurrencyB for a particular account.
Account1 has a transaction does not work CurrencyA and CurrenyB then Account2 has only transaction to CurrencyB.
My current query result is that the 3 first lines, what I need is the 4th should also appear and be included.
CurrencyA - amount - account1
CurrencyB - amount - account1
CurrencyB - amount - Account2
CurrencyA - < '0' / or null >-Account2
I think that my request is based on the currency < x > I have, so it should be for each account, he has all the lines for each currency.
If please notify and let me know your thoughts.
Kind regards
Hello
It looks like you want an outer join partitioned.
I hope that answers your question.
If not, post a small example of 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
-
How do you check mysqli_numrows ($result) for lines nil?
I tried a query in PHPmy admin for a single record, and he returned
0-0 1 lines total.
Did the same for a nonexistent record and it came with zero results (empty)
So it seems you need to do some math to whow several lines, there is, as it seems to return 0 when there is only a single record and 0 when there is none.
How do you check mysql_inumrows ($result) for zero rows returned?
Its maybe related to the fact that save shots start at 0.
H Walker
I don't use mysqli, but you should be able to do the following:
If (! mysqli_numrows ($result) {})
no lines have been returned
}
You're right PHPmyAdmin starts its numbers of transfer line with zero, not 1, so if there are 25 lines, they are listed as 0-24 lines, mysqli_numrows reports the sum, so it takes 1, not zero.
Brégent, according to me, he was just using PHPmyAdmin to test his query.
-
How to get the positive result of the search text page number?
How can I access the results of search text of javascript page number... (using the batch sequence)
search.matchCase = false;
search.wordMatching = "MatchPhrase;
Search.Bookmarks = true;
Search.Query ("whatIMSearching", "ActiveDoc");
....
get page numbers,
then do something like the export of pages that have this text in their...
Use the javascript method getPageNthWord.
Maybe you are looking for
-
Is there a workable Win 7 audio driver for this machine? I tried the Lenovo support site, and the Configurator says: something to the effect of "no results found". This machine has been purchased from geeks.com as a refurbished PC before they close t
-
The drivers are all ok. Must have dislodged something but it is not clear. Any suggestions? It's a HP ISTART 2479 running Vista. Thank you
-
Windows has prevented my device Infarred "Serial Cable using IrDa Protocol" to 43 of the Labour Code
Windows has prevented my device Infarred "Serial Cable using IrDa Protocol" to 43 of the Labour Code Can someone help me with this please. Can I change the value and it Peel attention but in a few moments it will return on attention. I have no idea h
-
My computer crashed and I reinstall first elements 7, but it will not recognize my serial number there are two on the CD case please help
-
da quando ho da Windows10 Photoshop CC 2015 non riesce ad aggiornarsi?
Da mi sempre error ' Altra istanza del prodotto e in attesa dell' all'istallazione.» Attendi he finished. "