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 *
Related
I am currently working with Google Forms and want to rearrange the way the responses are being displayed on the "Response Sheet". The only way I can think of doing this is by importing or moving the data to another sheet that would select and transpose certain columns if Column A contains key value.
This is what I'm seeing as part of the input and would like to see as the output if Column A Contains certain text:
Input & Output
Thank you in advance for your help!
O.K.
I rewrite headings a2:e2,
I take whole first five columns without headings e3:e6
I display content of columns A,B,F,G,H for all the rows that have 'A1' in column 1
I take tables built in point 1 and 2 together and sort them by first column
My solution is here:
https://docs.google.com/spreadsheets/d/1n7Ppd8v75mb3qrnJz_Jh_b4HNaj4i56X9wRGnz0l6i8/copy
={A2:E2;
sort({A3:E6;
query(A3:H6,"select A,B,F,G,H where A ='A1'",0)})
}
I've got a csv from a 3rd party that is imported into Excel that I cannot figure out how take the data that looks like this so that each row is collapsed down and the blanks are gone. In SQL I would just do a select on the fields I want and de-dupe those, then max on the others to get rid of the blanks. How would this be done in Excel?
Data:
Expected results:
Assumption:
1. you only need to do this once
2. Your source data starts at A1 (the headers)
3. The list of IDs are sorted and with fixed number of rows for each ID (6 rows in your example) .
Steps:
Create a new worksheet
Fill column B with the list of unique ID (in the same order as your data), start with B1
Fill column A with a serial number: 0,1,2,3,4.... up to the number of unique IDs, start with A1
Fill in column C the following formula
=TEXTJOIN("|",TRUE,OFFSET([src worksheet]!$B$2:$O$7,A1*4,0))
Then you should be able to use "TextToColumn" function to make the table you want.
I have this formula in my sheet:
=query('Character Analysis'!$H62:$L83,"select H,I,J,K,L where H is not null order by L DESC",0)
Only the first two of the source rows have data in them, but on the sheet with the query formula it appears to be pulling all the rows in the range, even the blank ones. If I type something in the 3rd row on the query formula sheet, it gives me an error saying "Array result was not expanded because it would overwrite data in ________." But it doesn't need that room because there are only two rows of data in the query result.
I tried adding the "is not null" language in hopes that it would limit the returned result to only filled cells, but it's not working.
How can I tell my query to only pull data from filled cells in the source range?
I figured out a workaround, at least to the degree that it works for me. It's not a true answer as I'd still like to know why the "is not null" language isn't working, but this is giving me exactly what I need: You can just limit the number of returned rows to the number of source rows with data by counting them:
=query('Character Analysis'!$H62:$L83,"select H,I,J,K,L order by L DESC limit "&COUNT('Character Analysis'!$L62:$L83)&"",0)
According to source
You can:
Using a ‘where’ clause to eliminate blank rows
If a named range is defined using entire column (ie including blank rows) you may find these blanks appear in the query result (which, depending on the sort order, could be at the top!). To stop these appearing include a where clause using this syntax (assuming column A):
"...where A <> ' ' " (for text fields)
"...where A <>0" (for numeric fields)
This means ‘where values in column a are not zero-length text.
I have an table in an MS Excel 2010. The table has two columns. The first column is a name of a person (Col A), the second column is the marks that the person secured in an exam (Col B).
I am applying conditional formatting. If I choose the following wizard
Home > Conditional Formatting > Format all cells based on their values
I can color the Col B on a 3-color scale. This is exactly what I want. However, I want it for the entire row and not only the cell in Col B. I want the name also to be formatted in the same color as the marks.
Anyone knows how to do this?
I have already looked around a bit. The following came close to did not solve the particular problem that I am trying to.
http://www.howtogeek.com/howto/45670/how-to-highlight-a-row-in-excel-using-conditional-formatting/
Conditional Formatting Rows Based on Date
You're probably going to have to use VBA code for this.
Right click the worksheet label and select 'View Code'
Inside the code window, paste in the following code:
Sub RunMe()
Dim xRng As Range, xCell As Range
With Me
Set xRng = .Range(.Cells(2, 2), .Cells(.Rows.Count, 2).End(xlUp))
' Change the first '2' above to reflect the starting row of your data
For Each xCell In xRng
xCell.Offset(0, -1).Interior.Color = xCell.DisplayFormat.Interior.Color
Next xCell
End With
End Sub
Now every time you run the macro (Alt-F8, select macro), column A will be formatted with the conditional formatting assigned to column B.
If you want this process to be automatic, change:
Sub RunMe()
to something like:
Private Sub Worksheet_Activate()
' This will run the macro whenever the worksheet is selected
or you could assign the code to a keyboard shortcut or a command button etc.
If you would like the code to run every time the file is opened, saved closed etc, add the code instead to the ThisWorkbook code window (although you'd have to alter the code slightly as 'Me' is referencing the particular worksheet in which the code is placed).
Google Forms - I have set up a google form and I want to assign a unique id each of the completed incoming form inputs. My intention is to use the unique ID as an input for another google form I have created which I will use to link the two completed forms. Is there another easier way to do this?
I'm not a programmer but I have programming resources available to me if needed.
I was also banging my head at this and finally found a solution.
I compose a 6-digit number that gets generated automatically for every row and is composed of:
3 digits of the row number - that gives the uniqueness (you can use more if you expect more than 998 responses), concatenated with
3 digits of the timestamp converted to a number - that prevents guessing the number
Follow these instructions:
Create an additional column in the spreadsheet linked to your form, let's call it: "unique ID"
Row number 1 should be populated with column titles automatically
In row number 2, under column "Unique ID", add the following formula:
=arrayformula( if( len(A2:A), "" & text(row(A2:A) - row(A2) + 2, "000") & RIGHT(VALUE(A2:A), 3), iferror(1/0) ) )
Note: An array formula applies automatically to the entire column.
Make sure you never delete that row, even if you clear up all the results from the form
Once a new submission is populated, its "Unique ID" will appear automatically
Formula explanation:
Column A should normally hold the timestamp. If the timestamp is not empty, then this gives the row number: row(A2:A) - row(A2) + 2
Using text I trim it to a 3-digit number.
Then I concatenate it with the timestamp converted to a number using VALUE and trim it to the three right-most digits using RIGHT
Voila! A number that is both unique and hard-to-guess (as the submitter has no access to the timestamp).
If you would like more confidence, obviously you could use more digits for each of the parts.
You can apply unique ID numbers using an arrayformula next to the form data. In row 1 of the first rightmost empty column you can use something like
=arrayformula(if(row(A1:A)=1,"UNIQUE ID",if(len(A1:A)>0,98+row(A1:A),iferror(1/0))).
A few comments regarding the explanation provided by #Ying, which I will try to expand, as it is very good.
> Column A should normally hold the timestamp.
In my case, it is date+time stamp.
> 4. Make sure you never delete that row,
even if you clear up all the results from the form
That issue can easily be avoided by placing the formula in the header like this
={"calculated_id";arrayformula( if( len(C2:C); "" & text(row(C2:C) - row(C2) + 2; "000") & RIGHT(VALUE(C2:C); 3); iferror(1/0) ) )}
This formula provides an string for one cell, and a formula for the next one, which happens to be an array formula which will cover all the cells below.
Note: Depending on your language settings you may need to use ";" or "," as separator among parameters.
> 5. Once a new submission is populated,
its "Unique ID" will appear automatically
Issue
And here is the issue I see with this solution.
If the Google Form allows responders to Edit their responses, the date+time stamp will change and so the calculated_id.
A workaround is to have 2 columns, one is the calculated_id and the other will be static_id.
static_id will take whatever is on calculated_id only if itself has no data, otherwise it will stay as it is.
Doing that we will have an ID that will not change no matter how many updates the response experience.
The sort formula for static_id is
=IF(AND(IFERROR(K2)<>0;K2<>"");K2;L2)
The large one is
={"static_id";ArrayFormula(IF(AND(IFERROR(M2:M)<>0;M2:M<>"");M2:M;L2:L))
}
M or K -> static_id
L -> calculated_id
Remember to put this last one on the header of the column. I tend to change the color to purple when it has a formula behind, so I don't mess with it by mistake.
Extra info.
The numeric value from the date/time stamp differs when it comes from both or just one. Here are some examples.
Note that the number of digits on the fractional part differ quite a lot depending on the case.