I want to try increase the width of my first column on a returned result, but it is being cut off by the second column, I have tried linesize but this does not seem to work?
say the column name is col1.
Before executing any select add this line to the command script, test it on the sqlplus command line --- I'm assuming col1 is VARCHAR2.
-- this makes col1 15 characters wide
COL col1 format a15
Related
I have 2 columns of numbers, the idea is to find the first & last value in column L that respects a criterion and return the value from the same row in column K.
As the criterion is "higher than 99% of the max value in column L", I tried the MINIFS formula, but I cannot use this as a criterion.
I guess the solution will include the MATCH, INDEX formula but I cannot find the right combination
In this specific example, we want to return the value of the first column that has in column L a number higher than 0,99*max(L3:L62)(=3.0879...) so it should return 19
This will be verified for a couple rows until the value goes below the 99% again. This last row is 58.
Link to sheet :
https://docs.google.com/spreadsheets/d/1MUkYDPoR1NxB8qWcYr_2Fp91FgUbnUOpfGd7EUuWCOg/edit?usp=sharing
You can also try the following:
For first value
=Index(K3:K62;Min(IFERROR(1/(1/((Row(K3:K62)*(L3:L62>0,99*max(L3:L62)))))))-2)
For last value
=Index(K3:K62;Max(IFERROR(1/(1/((Row(K3:K62)*(L3:L62>0,99*max(L3:L62)))))))-2)
Try
=query({K3:L62};"select Col1 where Col2 > "&substitute(to_text(0,99*MAX(L3:L62));",";".")&" limit 1";0)
query as app script needs US notation in values (dot instead of comma)
to get the last row
=query({K3:L62};"select Col1 where Col2 > "&SUBSTITUTE(to_text(0,99*MAX(L3:L62));",";".")&" order by Col1 desc limit 1";0)
Imagine I have this (time)sheet:
Hours | Text
------+----------------------
3 | fixing PRA-345
4.5 | refactoring PRA-222
5 | PRA-345 and stuff
And I want to calculate how much cumulative time one has spent on a ticket with a given number.
In other words sum the hours based on the text in a neighbouring cell.
Can you do it without extra column? what I did was to make an extra column that returned either the number, if given text was present (via REGEXMATCH) or 0. And then I ran a SUM on that column. Having this solved without extra column would be nice ;)
Expected output
In my case if would be enough for a given string to find the total sum of hours. So if I cell(say it's D1) has the hardwired text, such as "PRA-345" I want the cell to the left(E1) to display the total hours(8 in this case)
Is this what you need?
=sum(filter(B5:B,regexmatch(C5:C,E5)))
Reference:
FILTER
SUM
Instead you can try
=QUERY({A1:A11,ArrayFormula(REGEXEXTRACT(B1:B11,"PRA-\d+"))},
"select Col2, sum(Col1) where Col1 is not null
group by Col2 label Col2 'Tickets', sum(Col1) 'Sums' ",1)
Functions used:
QUERY
ArrayFormula
REGEXEXTRACT
Using Informix dbaccess e.g.
select col1, col2, col3 from MyTable
may output results like this
col1 col2 col3
100 The first row blah blah
101 The second row more blah blah
or it may output results like this
col1 100
col2 The first row
col3 blah blah
col1 101
col2 The second row
col3 more blah blah
I need to make it choose one output format and stick with it so that I can parse it in a regular way.
Can I make it always output in either one style or the other?
I can use unload to and get a regular a|b|c format, which is nice, but
I require the column names to be outputted
I do not control the query, this has to work for an arbitrary SELECT, so I do not know the column names in advance
How can I force the output to be
always of a certain (any) fixed format
which includes the column names
?
I'm busy with creating an spreadsheet where I can get the average price of holidaydeals with a specific tag (f.e. a destination). When I do this for only one tag column the formula is working :) :
=averageifs(C4:C10,E4:E10,L1,F4:F10,"Frankrijk vakantie")
But... I have more then 10 tag columns in total and in every column something like "Frankrijk vakantie" could be found. My simple mind thought, okay lets change F4:F10 (in this example) to F4:G10 to look for "Frankrijk vakantie" in two columns. But... the formula didn't work.
Link to spreadsheet: https://drive.google.com/file/d/1Gw5VC5qT1bzbFIPBu5j4dLXBmJjh7GuW/view?usp=sharing
I've also added a screenshot. I hope that someone can help me with this. Would be great, thank you!
In L2 try
=query({C4:C11, ArrayFormula(N(mmult(N(F4:O11="Frankrijk vakantie"), transpose(column(F3:O3)^0))>0))}, "Select AVG(Col1) where Col2 > 0 label AVG(Col1) '' ")
and see if that works?
EDIT: to include a month/year filter try
=query({C4:C11, ArrayFormula(N(mmult(N( (F4:O11="Frankrijk vakantie")*(E4:E11=L1)), transpose(column(F3:O3)^0))>0))}, "Select AVG(Col1) where Col2 > 0 label AVG(Col1) '' ")
The formula makes use of a virtual array, containing the values of column C and the output of the mmult() function. The latter creates a column with 1's if 'Franrkijk vakantie' is found in that row AND the date in column E matches the date in L1. The query then averages the values from column C and filters out the rows where the conditions of the MMULT() are not met.
EDIT 2: To check for a 'double match' in the row, try
=query({C4:E11, transpose(query(transpose(F4:S11),,9^99))}, "Select AVG(Col1) where Col3='"&L1&"' and Col4 contains 'Frankrijk vakantie' and Col4 contains 'Europa vakantie' label AVG(Col1)''", 0)
Change range to suit.
Both of these are reading right so I have the link and the sheet and all the info correct, it's just outputting a little strange. I believe it's the same issue on both of them. Any help much appreciated.
1st issue:
=query(importrange("link","b9:d1000"),"Select Col3 where Col1 = '"&C4&"' ")
When I do this one it needs two rows. It puts the value I want in the first one and leaves the second row blank. As in, if I put anything in the second row, it gives me #REF can't overwrite that cell.
2nd issue:
=query(importrange("link","b9:d1000"),"Select max(Col3) where Col1 = '"&C4&"' ")
When I do this one It gives me two rows: the word "max" and then below it the actual max value. How do I get it to give me just the max value
These are different issues. In the first, there happen to be two rows that meet the condition in where; the second of them has empty Col3. If you want only one result, either revise the where condition by adding some additional requirement, or put limit 1 at the end of query string, to make sure only one row is returned.
"Select Col3 where Col1 = '"&C4&"' limit 1"
Second issue: "max" is the name given to the output column. This name can be changed to empty string with label max(Col3) '', which will eliminate the cell with the name.
"Select max(Col3) where Col1 = '"&C4&"' label max(Col3) ''"