Is there a way to pass the result of a query in another query in Google Sheets?
My use case example
=QUERY(form;"select * where D like here is where i need my result of another query";1)")"
the other query --> QUERY(another_range;"select * ";0)
Thanks in advance
use:
=QUERY(B2:D; "where B = date '"&TEXT(G2; "yyyy-mm-dd")&"'"; 1)
or if you want it hardcoded:
=QUERY(B2:D; "where B = date '2021-02-10'"; 1)
Related
I'm trying to import any row from the URL where column 1 contains the string 6293. When I execute this query all I get is the first row from the URL which does not contain the string 6293. BTW if I change the "where 1" clause to "where col1" I get an error. What am I doing wrong?
=query(importrange("URL","Cost Per SKU!a1:q1000"),"select * where 1 = '6293'")
try:
=QUERY(IMPORTRANGE("URL", "Cost Per SKU!A1:Q1000"),
"where Col1 = '6293'")
or:
=QUERY(IMPORTRANGE("URL", "Cost Per SKU!A1:Q1000"),
"where Col1 = 6293")
I have this query
$installments = Installment::where('merchant_id',1)->with('bills')->get(); .
and I need to get sum() of bill_amount column where exists in bills tables .
I have tried this in controller:
$paid_amount = 0;
$not_paid_amount = 0 ;
foreach ($installments as $installment) {
$paid_amount += $installment->bills->where('status',1)->sum('bill_amount');
$not_paid_amount += $installment->bills->where('status',0)->sum('bill_amount');
}
this work but I think it's not best practices,
What is the best way to do that?
thanks in advance
I think you can better have a view in DB combining the two tables and does the summation and then select from the view.
you create in DB something like :(needs to be tweaked as per ur tables)
CREATE or replace VIEW `merchatnt_bills` AS select sum(`bill`.`bill_amount`),`mr`.`merchant_id` AS `merchant_id`
from ((`merchant` `mr`, `bills` `bill`) join `farms` `f`) where ((<put one to many relatuion between two tables>) and (<any other condition u like>)
group by <columns>)
I'm trying to learn linq..I have the following linq query..
var abc = consumers.Where(w => plays.Any(x => x.consumerid == w.consumerid));
I would appreciate if someone could help me with its corresponding sql query.
consumers have just two fields.. consumerid and period both string.
plays also have two fields.. consumerid and playid both string.
Based on answer here.. I tried abc.ToString() but that did not help..
Simplified query:
SELECT *
FROM consumers x
WHERE EXISTS
(
SELECT *
FROM plays w
WHERE x.consumerid = w.consumerid
)
Try this:
select * from consumers c left join palys p on c.consumerid = p.consumerid
I would like to add a computed field in my select result using Eloquent.
$dbEntry->query->select('id', '(s1 + s2) as scoreSum')->toSql();
// "select `id`, `(s1` as `s2)` from `mytable`"
I would expect:
// "select `id`, `s1` + `s2` as scoreSum from `mytable`"
Context: in my real world stuff, what I am computing is an haversine formula (on a limited set of entries).
You need to use a raw query instead, e.g. like this:
->select(DB::raw('id, (s1 + s2) as scoreSum'))
Make sure you import the DB as well.
How I can use Like query in LINQ ....
in sql for eg..
name like='apple';
thanks..
Use normal .NET methods. For example:
var query = from person in people
where person.Name.StartsWith("apple") // equivalent to LIKE 'apple%'
select person;
(Or EndsWith, or Contains.) LINQ to SQL will translate these into the appropriate SQL.
This will work in dot notation as well - there's nothing magic about query expressions:
// Will find New York
var query = cities.Where(city => city.Name.EndsWith("York"));
You need to use StartsWith, Contains or EndsWith depending on where your string can appear. For example:
var query = from c in ctx.Customers
where c.City.StartsWith("Lo")
select c;
will find all cities that start with "Lo" (e.g. London).
var query = from c in ctx.Customers
where c.City.Contains("York")
select c;
will find all cities that contain "York" (e.g. New York, Yorktown)
Source
name.contains("apple");
I use item.Contains("criteria"), but, it works efficiently only if you convert to lower both, criteria and item like this:
string criteria = txtSearchItemCriteria.Text.ToLower();
IEnumerable<Item> result = items.Where(x => x.Name.ToLower().Contains(criteria));