Informix-SE 4.10, 7.32 and IDS 11.70: I have an index on a DATETIME YEAR TO FRACTION column I recently added as a timestamp to a table with ~800K rows. This column is being populated as users update or add new rows. So far, ~7K rows have DATETIME values, but the rest are NULL. How does SE and IDS treat the rows with NULL valued DATETIME columns when querying, updating and sorting?.. Are those rows ignored? The reason for the index is to support a query to find the most recently added or updated row with a "select max(datetime_col)" statement. Would a descending order index on this column provide better performance?
Sorting for a descending order the NULLS will be the last, in the ascending (default) will be in the top.
But the way it is treated depend on the way you filter your data.
You cannot compare NULL with a value, it is always false.
Hence, if in that table you try to fetch all rows in which the date is greater than CURRENT the rows with the column in NULL will not be fetch.
In a similar away if you try to fetch all rows in which the date is lesser than CURRENT the rows with the column in NULL will not be fetch.
What you want is to test it if it IS NULL or IS NOT NULL.
Related
I have a spreadsheet with multiple columns. Each column represents a recipe. Each column has a week number (e.g. 2, 3, 4)... Below the week number, we have a variable number of ingredients. I want to be able to merge all the ingredients from a given week into a single column.
Sample Data
I know how to statically merge ranges e.g. {B4:B20;C4:C20} and I can also think of using an if statement to check the week value e.g. =if(B1=2,{B4:B20;C4:C20}) but that's not close to what I want. I need to check the range B1:Z1 for the value of the week and if that value is X (let's say 2) then take the ingredients in B2:B and tack them on to C2:C and so on...
If I'm understanding you correctly, this should do it:
=QUERY(FLATTEN(FILTER(B3:Z,B1:Z1=2)),"WHERE Col1 Is Not Null")
FILTER keeps (i.e., "filters in") only the data in B3:Z where the header is 2.
FLATTEN forms one column (blank cells and all) from the FILTER results.
QUERY keeps only non-blank (i.e., Is Not Null) entries from that single-column list.
Image of formula not working
I am trying to filter data by column reference
Not Work For Me =UNIQUE(A2:C6)
What i want it shoutd be like What actually i want
I want find UNIQUE Data Through Column Reference B is Mo No.
Solution
In this case a simple UNIQUE statement is not enough. You are looking for a function that takes in account only one column for your uniqueness check.
In this case SORTN is best suited for this job.
=SORTN(A1:C7,7,2,2,1)
Here is how it works:
n: The number of items to return. Must be greater than 0.
I have 7 rows so at most 7 results
display_ties_mode: A number representing the way to display ties.
In this case 2: Show at most the first n(7) rows after removing duplicate rows.
sort_column1: The index of the column in range or a range outside of range containing the values to sort by.
In this case is 2 as well. Since the uniqueness check is performed in the B Column.
is_ascending: TRUE or FALSE indicating whether to sort sort_column in ascending order.
This is up to you
I have two tables. One table contains a column with dates and a column with exchange rates. A second table allows a user to enter any date and returns the exchange rate from the other table.
The lookup between the dates should search for the date that is closest to the entered date but never a future date (past or same date). How can I achieve this?
This is what vlookup is for.
=vlookup(D2, A2:B, 2, True)
Here D2 is search key, A2:B the range in which to search (1st column is searched), 2 is the number of column from which to return the result. True means the following:
If is_sorted is TRUE or omitted, the nearest match (less than or equal to the search key) is returned. If all values in the search column are greater than the search key, #N/A is returned.
Also works as an arrayformula, looking up all D values at once:
=arrayformula(vlookup(D2:D3, A2:B, 2, True))
I'm trying to remove duplicates based on one column and keep the last entry. Right now my formula is keeping the first value.
I'm using the formula found in this post:
Selecting all rows with distinct column values - Google query language
Well the short answer is just to change 0 (or false) in your formula to 1 (or true) so that VLOOKUP matches the last entry for each unique value
=ArrayFormula(iferror(VLOOKUP(unique(Data!D:D),{Data!D:D,Data!A:D}, {2,3,4,5},1 ),""))
This does appear to work for your test data
but that isn't the end of the story.
If you use VLOOKUP with this formula the data has to be sorted on the lookup column according to the documentation but in the comments above you said that you can't assume the data is sorted on the lookup column. Things do go horribly wrong if you try this on unsorted data. So you have to sort it on the lookup column like this
=ArrayFormula(iferror(VLOOKUP(sort(unique(Data1!D2:D),1,true),sort({Data1!D2:D,Data1!A2:D},1,true), {2,3,4,5},1 )))
the only slight downside being that this doesn't include the headings (because they would get sorted to the end of the data).
Here is the same test data sorted in descending order on ID
This gives the correct result (but without headers)
You can add the headers just by putting
=query(Data1!A:D,"select * limit 0")
above the data.
So I have this spreadsheet with data in it, there are 29 columns and 54 rows.
On the 2nd sheet I'm trying to find all of the rows that fit a certain criteria.
For some reason, if I include the column X in my query data, the results are completely messed up. The 1st row of the result is just concatenating the first 23 rows together whether they fit the criteria or not. If I only include up to Column W the query is OK and it returns the correct results. But the problem is that I need to get data from Columns A and AB, so I need to include column X in my data range.
In this spreadsheet you can see the data on Sheet1, the query that includes column X on Sheet2, and on Sheet3 I have the same exact query except it only goes up to Column W and you can see the correct results there.
Basically, I need the query to return the value of Column A and Column AB for every row where Column B is marked with an "x".
Here is the sheet
Include the third parameter of query, which is the number of header rows:
=query(Sheet1!A2:X, "select A where B='x'", 1)
The parameter is optional, but if it's omitted, query will guess the number of header rows based on the data. Sometimes it guesses correctly, sometimes not (hence the dependence on what columns are included in the query). In your case, it decided that the table had 23 header rows and concatenated them in the output.
I don't know why you have arrayformula wrapper for query, it does not really do anything.
This is a duplicate of https://webapps.stackexchange.com/questions/103761/how-do-i-get-query-to-return-the-right-data which I answered hours ago:
You can use the Filter function to do this , with a literal array :