I need to generate an Excel based on a sql query. The Issue is when I open the Excel the DTIME does not show the seconds unless I format the cell in Excel. Also the Test_ID is 14 Digits and shows as exponential form in Excel.
I have looked through so many forums and could not find a solution yet. Any help/advise will be greatly appreciated.
SET LINESIZE 32767;
SET PAGESIZE 32767;
SET FEEDBACK OFF
SET MARKUP HTML ON SPOOL ON
SPOOL D:\TEST.xls;
Select
TO_CHAR(DTIME, 'MM/DD/RRRR HH:MI:SS AM') DTIME,
(TEST_ID ||' ') AS TEST_ID,
From
TEST_DETAILS enqd
Where
enqd.RUN_DATE >= sysdate - 15/1440
Order By
enqd.RUN_DATE
/
spool off;
exit;
Converting that field from Number to Text is an option.
Related
I am writing the below sql code and using sqlplus.
SET HEADING ON
set linesize 2000 pagesize 10000
set feedback off verify off trimspool on trimout on
SELECT
ID||'|'||
Department||'|'||
Role||'|'||
FROM my_table;
I would like to print the all the rows in my_table to a txt filr. I am also trying to print the headers. Below is the output,
ID||'|'||Department||'|'||Role
--------------------------------------------------------------------------------------------------
111|IT|Consultant
222|HR|Adminstrator
What I would like the output be is:
ID|Department|Role
111|IT|Consultant
222|HR|Adminstrator
I would like the separator between the heading be | instead of ||'|'||
I do not want the line (----) below the heading
Also is there anyway to not list out all the column names and use select * instead and still getting all the formatting. I might have a dynamic table - hence do not want to change the code each time and want to do a select *
I have imported a CSV file to the spreadsheet that includes columns with Dates and timestamp (Columns D,E,K,L) and I'm currently facing 2 problems with these columns.
Some rows are formatted as text/string and I can't seem to change it to date format. I tried manually changing it via format>number>datetime but it remains the same.
the format of the date is being read incorrectly by spreadsheet. For example, 5/11/2018 is being read as May 11, 2019 but if you try to review the spreadsheet, it should be read as November 5, 2018. I tried playing with the format and spreadsheet settings to no avail.
Spreadsheet Sample
I'd appreciate any inputs.
UPDATE
For Column D & E, I have already converted all rows to Date but the problem persists where in some rows are being read as DD/MM/YYYY and some rows MM/DD/YYYY. This creates date discrepancy when I try to make data visualization using these data:(
I am unable to convert all rows in Column L to date format. Some rows are still being read as text/string.
if you have a spare column you can use this formula to correct it:
=DATE(RIGHT(A1; 4); MID(A1; 4; 2); LEFT(A1; 2))
also, you can try to change locale settings in your spreadsheet because it looks like that your spreadsheet uses mm/dd/yyyy format as default. eg. you can try for example Czech locale where default is dd/mm/yyyy
To format custom dates in Google Sheets:
Highlight the column to be formatted.
Navigate the app's menu path:
Format >> Number >> More Formats >> More data and time formats
Put your cursor in the top field of the popup and edit as necessary...
Delete parts you don't want.
Add parts you do want (but make sure you're adding them left-to-right).
Put character(s) between the fields as separators.
Format each part via its dropdown list of options.
Click the "Apply" button, and you're done.
Is it possible to filter values from comlex metric in grafana?
For example:
SELECT sum(one) + sum(two) FROM "table" WHERE $timeFilter GROUP BY time($interval)
I need to show only positive sum sum(one) + sum(two) > 0
In sql I would use alias and HAVING clause like:
SELECT sum(one) + sum(two) AS S FROM "table" WHERE $timeFilter GROUP BY time($interval) HAVING S > 0
However that does not work in grafana.
How can I achieve this result without creating a new sum column in back-end database?
[EDIT]: My grafana GUI looks like this:
After clicking on "pen" button:
As of August 2016, the HAVING clause is not yet available in InfluxDB so finding all points where sum(one) + sum(two) > 0 is not possible directly in InfluxDB without using a continuous query to create an intermediate series.
However, Grafana does allow a minimum y-axis value to be set, which means any negative values will not be shown.
Hope that helps!
This answers just a part of your question but I was able to do the following in grafana+influxdb datasource:
Which selects the sum of one value if >0.
The problem is that it is not possible to select two different values in one query. But maybe you can workaround this problem with two querys in one graph.
Having the following statement:
SELECT * INTO ZZZD FROM P4978
Output:
result
time written
1970-01-01T00:00:00Z 231
Using:
SELECT * FROM ZZZD
I get only 7 lines even if there where 231 lines written. I can't figure why there are only 7 lines. Is there some setting or this is a defect? I'm not able to copy from a measurement to another measurement more than 7 lines.
If you want an exact copy use:
SELECT * INTO ZZZD FROM P4978 group by *
If you don't specify group by *, the tags will turn into fields.
You can verify the tags with show tag keys from ZZZD and the fields with show field keys from ZZZD
Source: https://docs.influxdata.com/influxdb/v1.5/query_language/continuous_queries/#common-issues-with-basic-syntax scroll to issue-4
Into clause is now working with influxDB 0.12 and above.
SELECT * INTO ZZZD FROM P4978
This will work
The INTO clause is intended for use with the downsampling continuous queries. Kapacitor is a better tool for copying data from one measurement to another.
I'm having trouble with two formatting issues that I would really appreciate help with:
1) The Days Open column is displaying the number of days properly, but the column name is being overwritten by my conversion command, and
2) I need the Order Date (OOpenDate) to be displayed in the "MM/DD/YYYY" format
Code:
column O_Num heading 'Order|Number' format a6
column OOpenDate heading 'Order|Date' format a10
column (sysdate-OrderOpenDate) heading 'Days|Open' format a4
select O_Num, OOpenDate, to_char(sysdate-OOpenDate, '999')
from Orders
where Status = 'Open';
What its currently displaying:
Order Order
Number Date TO_C
------ --------- ------
100 03-DEC-13 14
What I want it to display as:
Order Order Days
Number Date Open
------ --------- ------
100 12/03/2013 14
Thank you in advance!
The simplest approach would be to alias the "Days Open" column and apply the format mask to the alias
column days_open heading 'Days|Open' format a4;
select O_Num, OOpenDate, to_char(sysdate-OOpenDate, '999') days_open
from Orders
where Status = 'Open';
Otherwise, the column name in your column command would need to exactly match the expression in your SELECT statement (including the to_char, any spaces, etc.) That's possible but it generally makes things rather hard to maintain.