LIKE in IBM Informix SQL - informix

I have a varchar column "qty" defined in a table "order" which has 2 rows of data as follows
qty
3
3 1/9
When I try to use select query as
select * from order where qty like '3 %';
both rows which have qty 3 and 3 1/9 are returned, whereas I thought I would get only 3 1/9 which matches my lookup in like '3 %',
I even tried with trim(qty) like '3 %' also with the same result; I get both records.
There is no space after 3 in the first row.
Not sure why? Can someone help me here?

Try:
select * from order where qty like '3_%'.

In Java, there is a parameter you can add to your jdbc url:
;IFX_TRIMTRAILINGSPACES=0
In example:
jdbc:informix-sqli://dbhost:service/database:INFORMIXSERVER=ifxserver;IFX_LOCK_MODE_WAIT=1;IFX_TRIMTRAILINGSPACES=0
Hopefully, it will make the LIKE work the way you want

Related

Google sheets: Can I combine offset over range, based on dropdown?

I'm trying to build a yearplan for speedskating. Blah blah blah, context, what matters is that I can't work this bit out. I want "week type" to be filled with 1 to 10 cells, based on input from the "Cycle type". If I choose, for example, 6 wk, I want 6 cells (1, 2, 3, 4, 5, 6) and then be able to pick 3 wk below. I'm not sure how to do this, but I've come quite far already.
https://docs.google.com/spreadsheets/d/1EZ61f24t3SYAMkuTof6PjkcBNxSkVVdC5AJpxMoQrnM/edit?usp=sharing
This is the link to the sheet. This is the end result I'm trying to achieve
I'd appreciate some help, I've been stuck at this for quite some time! :)
I understand that you want to get "Cycle type" filled automatically according to "week type" form the input table like this.
In order to do that we need:
1 - Data validation in column 01 of output table from the input table "Cyclus type" we go Data > data validation - Criteria: list from range and select the range D3:D
2 - we need to normalize the input table, paste this QUERY fuction formula in Q3.
=QUERY({C3:D,F3:F;C3:D,G3:G;C3:D,H3:H;C3:D,I3:I;C3:D,J3:J;C3:D,K3:K;C3:D,L3:L;C3:D,M3:M;C3:D,N3:N;C3:D,O3:O}, " Select * Where Col1 is not null ")
Note that QUERY with Arrays {} in english local , to join columns side by side and ; to stack them, in Dutch however \ replaces , and ; is the same.
3 - we need a helper table by pasting this formula in W3 and drag down.
=IF(U3="",,TRANSPOSE(FILTER($S$3:$S,$R$3:$R=U3)))
Note: it can be hidden or collapsed using goups.
4 - Paste this formula to get all the results stacked under "Cyclus type"
=FILTER(FLATTEN(W3:AF),FLATTEN(W3:AF)<>"")
I hope that answres you question.

How can I reformat a "matrix report" in Google Sheets into a clean data sheet?

Sorry for the imprecise title, I'm not sure what this format is called. I received a "research database" in format you see below and need to convert it (and dozens more like it) into a useable format.
The sheets look like this:
COMPANY
Report 1
Report 2
Report 3
Report 4
Company 1
46.8
-0.2
0.2
Company 2
45.7
-0.3
I need to convert it to a properly formatted data sheet so I can upload it to a database. In other words, it needs to become:
Company
Report
Score
Company 1
Report 1
46.8
Company 1
Report 2
-0.2
Company 1
Report 3
Company 2
Report 4
0.2
Company 2
Report 1
45.7
Company 2
Report 3
-0.3
Company 2
Report 4
It's ok if we end up with rows with no value, those are easy enough to purge.
Sample sheet here
First, you'll want to delete what appears to be test data from A9:C of your "Data as Is" sheet.
After that, delete everything you currently have in the results sheet (or create a new blank one) and place the following formula in A1:
=ArrayFormula({"Company","Report","Score";SPLIT(QUERY(FLATTEN(IF('Data as Is'!B2:E="",,'Data as Is'!A2:A&"~"&'Data as Is'!B1:E1&"~"&'Data as Is'!B2:E)),"Select * WHERE Col1 Is Not Null"),"~")})
This will produce your headers and all results, with no-result rows already removed.
From there, you can format headers and data as you like.
Try this, where tab is your data
=query({
arrayformula(vlookup((roundup(flatten(sequence(columns(tab),rows(tab),1,1)/columns(tab)))),{flatten(sequence(columns(tab),rows(tab),1,1)),flatten(transpose(tab))},2,0)),
arrayformula(vlookup(mod(flatten(sequence(rows(tab),columns(tab),0,1)),columns(tab))+1,{flatten(sequence(rows(tab),columns(tab),1,1)),flatten(tab)},2,0)),
flatten(tab)
},"select * where Col1 is not null and Col2 is not null and Col3 is not null",0)

Google Sheets QUERY with WHERE on multiple columns

I'm building a Google Sheet table and I am stuck on a specific query I want to make
Source Table pic here
I need to sort my Names by "Type" and by "ValueType".
I managed to sort them by "Type" with ease, but i'm stuck on the sort by "ValueType" part, because they are in columns, not lines and I can't manage to find a way to sort them by columns
My Query looks like this right now
=QUERY(A1:G8; "SELECT * WHERE A='Type1'; 1)
I want it to look something like this :
=QUERY(A1:G8; "SELECT * WHERE A='Type1' AND C1:G1='ValueType 1'"; 1)
Is it possible to do something like this, and if so, can you please tell me what is the syntax?
Thanks in advance.
=QUERY(A1:G8; "SELECT * WHERE A='Type1' AND (C='"&C$1&"' or D='"&D$1&"') "; 1)
adding or X='"&X$1&"' within the () where X is the next letter.
'"&C$1&"' is the value in cell C$1 but you can adapt that for a different value on your sheet, or a fixed value using C='xxx'
You need to expand the formula, or you can do it too (if the number of columns is not fixed)
=QUERY({A1:G8}, "SELECT * WHERE Col1='Type1' and (" & "Col"&arrayformula(TEXTJOIN("='ValueType 1' or Col",,column(C:G)))&"='ValueType 1' )", 1)
try just that sentence to understand how it has been built
="Col"&arrayformula(TEXTJOIN("='ValueType 1' or Col",,column(C:G)))&"='ValueType 1'"

Google sheet query / filter with columns not Blank

I'am working on some document which get data from Non Google form, and the output is 36 column but there will be always filled up 8 max 9 columns with empty columns in between, with our Form we CANT change way how data are outputed. Empty column are here cuz Client fill up specific type of order so data are put in specific column.
i need query for pulling data from the main sheet and output just specific 5 specific column ( those will be always in same place ), and 2 columns that can be anywhere in between.
writing down every single column is not perfect as i need to pull data row by row not all at once ( i will be adding data in between final query output) and with that it would drasticly slow down file with few hundreds inputs added per week.
I didnt found working way to combine filter and query together to do this job ( removing empty columns [ <>'' and is not null].
Could someone help me with this ?
providing link for file : https://docs.google.com/spreadsheets/d/1SDR939yUSq9trLcxBid9AQeZUn-lNNiRr7O7pDiu888/edit?usp=sharing
In cell M1 of your sheet 'Desired output' try entering this little monster
=Arrayformula(query({'Raw data'!A:Z\
{"Configurable list"; 'Raw data'!D2:D&'Raw data'!F2:F&'Raw data'!H2:H&'Raw data'!J2:J&'Raw data'!L2:L&'Raw data'!P2:P&'Raw data'!R2:R&'Raw data'!T2:T&'Raw data'!V2:V}\
{"Date"; ('Raw data'!E2:E&'Raw data'!G2:G&'Raw data'!I2:I&'Raw data'!M2:M&'Raw data'!O2:O&'Raw data'!Q2:Q&'Raw data'!S2:S&'Raw data'!U2:U&'Raw data'!W2:W)+0}};
"Select Col1, Col2, Col3, Col26, Col28, Col24, Col27 Where Col1 is not null format (Col28) 'dd.mm.yyyy'"))
See if that works for you?
Your answer is really in the heading. You can use =filter([Range], [Range]<>"") for each row to get to this in the desired output. The filter function is perfect for this application.
UPDATE:
Looked at your sheet to get a better view of the problem. You'll need some wildcard workaround as shown here as a second criteria to identify the Date & Configurable cells: =filter([Range], [Range]<>"", search("Date", [Top row]))

Output a normalized column with a calculated field in QUERY

In Google Spreadsheet, I have the expression:
=QUERY(database; "select b,c, where a='anyone-condition' order by c desc";-1)
The column a,b are strings and c is a number.
How can I include in this query one calculated field, c/sum(c)?
Although Ed Nelson is perfectly right, you can be creative with multiple nested Queries and get desire result without an extra column.
I have build simple example that will show you the way
Data
Solution 1 - simpler but with ugly column name
=QUERY(
A1:C3,"select A,B,C/"&QUERY(
QUERY(A1:C3,"select sum(C)"),"select * offset 1",0)&"" ,1
)
Solution 1.1 - more complex but with custom column name
=QUERY(
A1:C3,"select A,B,C/"&QUERY(
QUERY(A1:C3,"select sum(C)"),"select * offset 1",0)&
" label C/"&QUERY(
QUERY(A1:C3,"select sum(C)"),"select * offset 1",0)&
" 'C/sum'",1
)
Finals:
You can go further and add formating to last column as well
Link to working copy
For your specific example probably code should be like this:
=query(database; "select b,"&query(query(database; "select sum(c), where a='anyone-condition' "),"select * offset 1",0)&" where a='anyone-condition' order by c desc";-1)
But, it should be tested against real data
Is that serves your needs?
You can't do a sum without doing a group which you don't want. You can add a column D to your sheet to sum. Try =sum($C$2:$C) in D and copy down. Then this will work:
=query(database, "select B,C/D where A='anyone-condition' order by C desc label C/D ''",-1)
The problem is with the Google Spreadsheet 'kernel', not with my coding. Look the scream that I printed
https://drive.google.com/file/d/1yJbcfVZ1tDmW8WoG224PALRIwyEbX9LH/view?usp=sharing

Resources