I've created a Google Sheets function, with the intended effect of getting the sum of numeric values between two dates, where the value in a different column is equal to a string. The calculation however is having unintended side-effects.
The problem is that the function starts out by returning the string value "sum" to the cell, before returning the actual result of the calculation onto a second row.
How can I limit the QUERY function in Google Sheets to only return the value of the calculation I'm querying for?
=QUERY('Finance, raw data'!A2:D;"SELECT SUM(C) WHERE D='Audible' AND A >= date '2021-08-01' AND A < date '2021-09-01'")
label it:
=QUERY('Finance, raw data'!A2:D;
"select sum(C)
where D ='Audible'
and A >= date '2021-08-01'
and A < date '2021-09-01'
label sum(C)''")
offset it:
=QUERY(QUERY('Finance, raw data'!A2:D;
"select sum(C)
where D ='Audible'
and A >= date '2021-08-01'
and A < date '2021-09-01'");
"offset 1"; 0)
index it:
=INDEX(QUERY('Finance, raw data'!A2:D;
"select sum(C)
where D ='Audible'
and A >= date '2021-08-01'
and A < date '2021-09-01'
label sum(C)''"); 2)
I am clear that there is no concat method in google sheets queries but I'm hoping for a workaround. I've seen some suggestions for transpose but can't seem to apply them to my use, hoping for help.
My actual source sheet has more complexity in columns but I've simplified it to demonstrate
Existing Query
=query($L$10:$N$27, "SELECT L, M WHERE N = 'Full' LABEL L 'Name', M ''",1)
If Concat/Append were available it would look more like
=query($L$10:$N$27, "SELECT ("Name is: " & L & " " & M) WHERE N = 'Full' LABEL L 'Name'",1)
Thanks!
try:
=ARRAYFORMULA(QUERY({"Name is: "&L10:L27&" "&M10:M27, N10:N27},
"select Col1
where Col2 = 'Full'
label Col1 'Name'", 1))
I want to use a query in Google Sheets that lets me look at a column of checkboxes to filter on ones that are checked (TRUE).
=QUERY(Available!$A$3:$O, "select A,B,C,D,E,F,G,H,I,J,K,L,M,N,O where O = '"& TEXT(TRUE) &"' and B > 100,000 order by B desc")
It is complaining of a literal value, but I am having a lot of trouble figuring out the proper syntax to ensure the query is reading the checkbox properly.
try it like this:
=QUERY(Available!A3:O,
"where O = TRUE
and B > 100000
order by B desc")
if the range is A:O and you want all columns you don't need select A,B,C,D,E,F,G,H,I,J,K,L,M,N,O
also TRUE is boolean so no need to treat it as TEXT
to fix ARRAY_LITERAL ERROR you need to build your formula like:
={IFERROR(QUERY(Available!A2:O, "select A,B,C,D,E,F,G,H,I,J,K,L,M where M like '%(Blah)' order by B desc"),
{"1","","","","","","","","","","","",""});
IFERROR(QUERY(Available!A2:O, "select A,B,C,D,E,F,G,H,I,J,K,L,M where C = 'BlehBleh' order by B desc limit 7"),
{"2","","","","","","","","","","","",""});
IFERROR(QUERY(Available!A2:O, "select A,B,C,D,E,F,G,H,I,J,K,L,M where O = TRUE and B > 100000 order by B desc"),
{"3","","","","","","","","","","","",""})}
I am currently using the DBI module to connect to my MSSQL Database to pull some data from a table.
The row I am trying to pull contains a lot of text (it is of type ntext and can contain up to 6Mb of text).
My query is a very simple one at the moment:
my $sql = "SELECT TOP 1 [reportRow] from UsageReport";
And I also have LongTruncOk enabled for the Database options.
After I execute the query, I want to display the rows.
while ( my #row = $sth->fetchrow_array ) {
print "#row\n";
}
Unfortunately it displays the data in a very weird manner with spaces in between every character and it only retrieves the first 40 characters.
< r e p o r t > < r e p o r t h e a d e r > < m o n t h > O c t o b e r 2 0
If I use File::Slurp to output #row to a file, it displays as
Is there a reason the data is being cut off and is being displayed weird?
Edit: How would I convert UTF16 into a format that doesn't insert spaces between characters?
You need to set LongReadLen in addition to LongTruncOk. You've told DBI it's ok to cut off long results from the DB, and now you need to tell it how long of a string you're willing to accept.
Suppose that my index has 3 fields: title, x and y.
I know one range(10 < x < 100) can query like this:
http://localhost:8983/solr/select?q=x:[10 TO 100]&fl=title
If I want to two range(10 < x <100 AND 20 < y < 300) query like
SQL(select title where x>10 and x < 100 and y > 20 and y < 300)
by using Solr range query or SolrJ, but I don't know how to implement this. Does anybody else know? Thanks
Email: enzhaohoo#gmail.com
Take a look at the docs for SolrJ. Successive calls to addFilterQuery will continue to build up your query. Alternatively you can have two things in one fq:
http://localhost:8983/solr/select?q=&fq=x:[10+TO+100]+AND+y:[20+TO+300]&fl=title
There is a method in class SolrQuery can solve your problem,
setFilterQueries(String... fq)
You can take a look at this.