How to suppress the output message in vertica - message

I am running a series of SQL statement in vertica which is saved in abc.sql file and transferring the output to a text file.
I wanted to suppress the warning message and stop it from going to text file
abc.sql
UPDATE public.aks SET name='Akshay';
SELECT 2;
SELECT 3;
SELECT 4;
output.txt
OUTPUT
100
(1 row)
?column?
2
(1 row)
?column?
3
(1 row)
?column?
4
(1 row)

This video I made a while back goes over several format options including what you are looking for: https://www.youtube.com/watch?v=d3f3fvMGDnU
If you add the -t option, it will not show you how many rows are returned or the column headers. Looks like you are already using the -A option, so adding the -t option should be all you need to create properly delimited file contents.

You need to switch output on and off within the script.
Preparing the table:
CREATE TABLE public.aks AS
WITH
-- need a series of integers ..
i AS (
SELECT MICROSECOND(ts) AS i , 'slartibartfast' AS name FROM (
SELECT TIMESTAMPADD(microsecond, 1,'2000-01-01'::TIMESTAMP) AS tm UNION ALL
SELECT TIMESTAMPADD(microsecond,100,'2000-01-01'::TIMESTAMP) AS tm
)x
TIMESERIES ts AS '1 microsecond' OVER(ORDER BY tm)
)
SELECT * FROM i;
Once that is done - the script looks like this:
-- send all output to nirvana
\o /dev/null
UPDATE public.aks SET name='Akshay';
-- send output back to screen
\o
SELECT 2;
SELECT 3;
SELECT 4;
And the output:
2
3
4
Is this what you're looking for?

Related

Playwright: Comparing the downloaded xlsx document with the expected one

Please, can you advise me how to compare the downloaded file with the expected one? I haven't seen anything like that anywhere. By the way, if I compare e.g. two xlsx files, so I would also like to have information about the different values in the cells.
Example
Fist xlsx file
Column A
Column B
1
2
3
4
Second xlsx file
Column A
Column B
2
1
4
3
Comparing result - example
----------------- DIFF -------------------
DIFF Cell at A2 => '1' v/s '2'
.
.
.
I thought I'd join the comparison https://github.com/vrootic/FileCompare

Oracle: SQLPlus headers appear with '||'|'||'. Headers gets cut halfway

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 *

Generate a list of all unique values of a multi-column range and give the values a rating according to how many times they appear in the last X cols

As the title says.
I have a range like this:
A B C
------ ------ ------
duck fish dog
rat duck cat
dog bear bear
What I want is to get a single-column list of all the unique values in the range, and assign them a rating (or tier) according to the number of times they have appeared in the last X columns (more columns are constantly added to the right side).
For example, let's say:
Tier 0: hasn't appeared in the last 2 columns.
Tier 1: has appeared once in the last 2 columns.
Tier 2: has appeared twice in the last 2 columns.
So the results should be:
Name Tier
------ ------
duck 1
rat 0
dog 1
fish 1
bear 2
cat 1
I was able to generate a list of unique values by using:
=ArrayFormula(UNIQUE(TRANSPOSE(SPLIT(CONCATENATE(B2:ZZ9&CHAR(9)),CHAR(9)))))
But it's the second part that I am not sure exactly how to achieve. Can this be done through Google Sheets commands or will I have to resort to scripting?
Sorry, my knowledge is not enough to build an array-formula but I can explain how I get it per cell and then expanded a range from it.
Part 1: count the number of nonempty columns (assuming that if column has something on the second row, then it's filled.
COUNTA( FILTER( Sheet1!$B$2:$Z$2 , NOT( ISBLANK( Sheet1!$B$2:$Z$2 ) ) ) )
Part 2: build a range for the last two filled columns:
OFFSET(Sheet1!$A$2, 0, COUNTA( ... )-1, 99, 2)
Part 3: use COUNTIF to count how many values of "bear" we meet there (here we can pass a cell-reference instead) :
COUNTIF(OFFSET( ... ), "bear")
I built a sample spreadsheet that gets the results, here's the link (I know external links are bad, but there's no other choice to show the reproducible example).
Sheet1 contains the data, Sheet2 contains the counts.
I suggest using both script and the formula.
Normalize the data
Script is the easiest way to normalize data. It will convert your columns into single column data:
/**
* converts columns into one column.
*
* #param {data} input the range.
* #return Column number, Row number, Value.
* #customfunction
*/
function normalizeData(data) {
var normalData = [];
var line = [];
var dataLine = [];
// headers
dataLine.push('Row');
dataLine.push('Column');
dataLine.push('Data');
normalData.push(dataLine);
// write data
for (var i = 0; i < data.length; i++) {
line = data[i];
for (var j = 0; j < line.length; j++) {
dataLine = [];
dataLine.push(i + 1);
dataLine.push(j + 1);
dataLine.push(line[j]);
normalData.push(dataLine);
}
}
return normalData;
}
Test it:
Go to the script editor: Tools → Editor (or in Chrome browser: [Alt → T → E])
After pasting this code into the script editor, use it as simple formula: =normalizeData(data!A2:C4)
You will get the resulting table:
Row Column Data
1 1 duck
1 2 fish
1 3 dog
2 1 rat
2 2 duck
2 3 cat
3 1 dog
3 2 bear
3 3 bear
Then use it to make further calculations. There are a couple of ways to do it. One way is to use extra column with criteria, in column D paste this formula:
=ARRAYFORMULA((B2:B>1)*1)
it will check if column number is bigger then 1 and return ones and zeros.
Then make simple query formula:
=QUERY({A:D},"select Col3, sum(Col4) where Col1 > 0 group by Col3")
and get the desired output.

Copy from a measurement to another measurement in InfluxDB

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.

Formatting: Changing Column Headers for SqlPlus Query

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.

Resources