column headings getting truncated - sql

i am running my query via a unix script. i need column headings. For this i have used set heading on. my requirement is to pull data from a table concatinate it using a pipe, write it in a text file. i need column headings along with the data.this file needs to be sent as feed to some other party. my query is something like this
select column1||'|'||column2||'|'||column3||'|'||column4......
from table;
I have more than 100 columns in my query
in my oputput the column data comes up correct but the column headings get truncated. i see dashes i.e '------' instead of column names after three column headings are displayed.
the output is something like
column1||'|'||column2||'|'||column3||'|'||col
--------------------------------------------------------------------------------
20-APR-13|0.990000|0|0|Y|voice|yes|0|0
20-APR-13|0.990000|0|0|Y|voice|yes|0|0
( in the above exmaple i tried with 9 columns. i can see data for 9 columns but the headings after 3 column headings the fourth one is truncated and rest are not displayed.)
I couldn't paste my original query with more than hundred columns here.
Can somebody let me know how to resolve it.

Use the configuration of the shell to set the column size:
COLUMNS=1024
stty columns 1024

Related

Number with a lot decimals in pentaho cde table component

i have 4 columns in a table of pentaho cde. the 1st column is a string the second and third column are numbers with a lot of decimals. i want this numbers in this format ###,## how can i do it in table component of pentahop cde.
On the table’s Column formats property set those columns with format ‘%.2f’, and the others as ‘null’

How to combine a row of cells in VBA if certain column values are the same

I have a database where all of the input from the user (through a userform) gets stored. In the database, each column is a different category for the type of data (ex. date, shift, quantity, etc) and the data from the userform input gets put into its corresponding category. For some of the data, all the data is the same except for the quantity. I was wondering how I could combine these rows into one and add the quantities to each other for the whole database (ex. combining the first and third data entries). I have tried playing around with a couple different loops but can't seem to figure anything out.
Period Date Line Shift Type Quantity
4 x 2 4/3/18 A 3 14 18
4 x 2 4/3/18 A 3 13 12
4 x 2 4/3/18 A 3 14 15
Thank you!
If you're looking to modify the underlying database, you might be able to query the data into the format you want by including all the other columns in a GROUP BY statement, save the result to another table, then replace the original table with the properly formatted one.
If you have the data in Excel and you just want to view it with the duplicate rows summed, a Pivot Table would be a good choice. You can select all the other columns as rows for the Pivot Table and sum of Quantity as the values.

sql: select rows with multiple lines of data

In table A -> Column X there is some data which has numbers, alphabets and special characters. Most of the records has single line of data but some of them has 2 or 3 lines of data.
1 this is a sample description of data 01/11/2017 # 123'~
Records with two lines of data
1 this is a sample description
2 of data 22/11/2017 #~ 12##'
I need to do a select query to get the records which has 2 lines of data in Column X of table A.
I use TOAD and the above mentioned sample data is from the Grid popup editor
thanks
You could select those rows that contain a new line (do not know your sample data, either chr(10) or chr(13)):
select *
from tableA
where instr(columnX, chr(10)) > 0;
The solution is taken from this SO answer, please do not forget to upvote the linked solution if it helped you.

Hive table with dynamic number of columns

TestTable
inputsCOLUMN
3-300-150-150-R
3-200-100-100-A
5-500-00-500-A
output
3_open 3_spent 3_closing 3_type 5_open 5_spent 5_closing 5_type
-------- --------- ----------- -------- -------- --------- ----------- --------
300 150 150 R 500 00 500 A
200 100 100 A
Above is the input table called TestTable. It has two columns that contains rows of data(strings)
And there is a desired output table of which the column names are based on the input string.
the column name is the first number on the string + another string name, like CONCAT(split(inputsCOLUMN,'\\-')[0],'-','type')
so that output is the desired output. and the below query is not working as desired because of that part when i am trying to concatenate an alias i think is not allowed. so help me if there is a way i can find that desired output.
SELECT split(inputsCOLUMN,'\\-')[1] as CONCAT(split(inputsCOLUMN,'\\-')[0],'-','open'),
split(inputsCOLUMN,'\\-')[2] as CONCAT(split(inputsCOLUMN,'\\-')[0],'-','spent'),
split(inputsCOLUMN,'\\-')[3] as CONCAT(split(inputsCOLUMN,'\\-')[0],'-','closing'),
split(inputsCOLUMN,'\\-')[4] as CONCAT(split(inputsCOLUMN,'\\-')[0],'-','type')
Hive cannot have a dynamic number of columns, and it cannot have dynamic column names. It must be able to determine the entire schema (column count, types, and names) at query planning time, without looking at any data.
It's also not clear to me how exactly you're matching up input records into a single row. For example, how do you know which "3" record corresponds to which "5" record.
If you knew that, for example, there would always be a "3" record and a "5" record and you could commit to those being the only column names, and if you had a consistent way of matching up records to "flatten" this data, then it is possible, but difficult. I've done almost this exact operation before, and it involved a custom UDTF and a custom UDAF, and some code to auto-generate the actual query, which ended up being hundreds of lines long in some cases. I would re-evaluate why you want to do this in the first place and see if you can come up with another approach.

SQL: Output Row Values to Distinct Count for Number of Instances

I'm trying to replicate an Access Formula that will output the Columns in Column "Distributions" to include distinct counts leading up to the value in Column "Count."
For example, if I have an order number that recurs in the data sheet for three lines, I would like the output in the "Distributions" column to count 1,2,3 for each line in the sheet. If there is one line to the order, I need only an output of 1 in the column, if there are 70 lines, I need an output of 1-70 for every matching Order Number.
I already have the "Count" column sorted out, but I can't wrap my head around the necessary code to make the output increment up in the "Distributions" column. The image below details the sort of output I'm looking for with Sample Data.