How can I combine this code into one or two LINQ queries?
Tag : chash , By : Nick Coats
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , I'm perhaps being a bit lazy asking this here, but I'm just getting started with LINQ and I have a function that I am sure can be turned into two LINQ queries (or one nested query) rather than a LINQ and a couple of foreach statements. Any LINQ gurus care to refactor this one for me as an example? , How about: const string xmlNamespace = "{http://schemas.microsoft.com/developer/msbuild/2003}";
return from projectPath in projectPaths
let xml = XDocument.Load(projectPath)
let dir = Path.GetDirectoryName(projectPath)
from c in xml.Descendants(xmlNamespace + "Compile")
where c.Attribute("Include").Value.EndsWith(".cs")
select Path.Combine(dir, c.Attribute("Include").Value);
|
How to combine these 2 queries into 1 and avoid extra code
Tag : php , By : David Marchant
Date : March 29 2020, 07:55 AM
I hope this helps you . I have 2 tables in database, table users lists all users and their inviters (referrers) , table donations lists all the donations SELECT COUNT(*) FROM donations d INNER JOIN users u ON d.user_id=u.id WHERE u.ref='$referrer' GROUP BY d.user_id
|
Given the VB.net code, combine multiple queries into 1
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further It looks like you're just needing to do an inner join on the two queries to get one result set. See if this works. If so, you can eliminate the second query and second inner loop. strSQL = "SELECT d.job, d.suffix, isnull(d.qty_scrapped,0), isnull(d.qty_released,0)," _
& " isnull(d.price,0), d.co_num, ISNULL(m.a_cost,0)" _
& " FROM vwDashboardsQuality d" _
& " INNER JOIN jobmatl m" _
& " ON d.job = m.job" _
& " AND d.suffix = m.suffix" _
& " WHERE trans_date >= '" & dtpStartDate.Value & "'" _
& " AND trans_date <= '" & dtpEndDate.Value & "'"
SELECT d.job, d.suffix, isnull(d.qty_scrapped,0), isnull(d.qty_released,0), isnull(d.price,0), d.co_num,
ISNULL(m.a_cost,0)
FROM vwDashboardsQuality d
INNER JOIN jobmatl m
ON d.job = m.job
AND d.suffix = m.suffix
WHERE trans_date >= '2015-09-29'
AND trans_date <= '2015-09-30'
|
How to combine multiple SQL queries into one to output as JSON in PHP code?
Date : March 29 2020, 07:55 AM
Any of those help I currently have the following table set up: , SQL: $sql = "SELECT * FROM table ORDER BY Day";
$result_object = [];
$item = 1;
while ($row = $result->fetch_assoc()) {
if(isset($result_object['day'.$row['Day']]))
{
$result_object['day'.$row['Day']]['item'.$item] = $row;
$item++;
}
else
{
$result_object['day'.$row['Day']]['item1'] = $row;
$item = 2;
}
}
echo json_encode($result_object, JSON_PRETTY_PRINT); //JSON_PRETTTY_PRINT is not necessary...
while ($row = $result->fetch_assoc()) {
if(isset($result_object[$row['Day']]))
{
$result_object[$row['Day']]->items[] = $row;
}
else
{
$result_object[$row['Day']] = (object)['day'=>$row['Day'], 'items'=>[$row]];
}
}
[
{
"day": "0",
"items": [
{
"StartTime": "07:23:56",
"EndTime": "17:24:04",
"Performer": "Performer1",
"Event": "Event1",
"Day": "0",
"Location": "1"
},
{
"StartTime": "09:24:30",
"EndTime": "01:04:37",
"Performer": "Performer2",
"Event": "Event2",
"Day": "0",
"Location": "1"
}
]
},
{
"day": "1",
"items": [
{
"StartTime": "10:25:22",
"EndTime": "11:25:29",
"Performer": "Performer2",
"Event": "Event3",
"Day": "1",
"Location": "2"
}
]
},
{
"day": "2",
"items": [
{
"StartTime": "12:26:08",
"EndTime": "13:26:12",
"Performer": "Performer3",
"Event": "Event4",
"Day": "2",
"Location": "1"
}
]
}
]
|
How to combine the code of two array queries in Google Sheets
Date : December 25 2020, 11:01 AM
To fix this issue I need to combine two queries that are both inside arrayformulas so that I just have one query: =ARRAYFORMULA(QUERY(REGEXREPLACE(TO_TEXT(QUERY({
QUERY({MONTH(MID('grouping project'!A2:A, 8, 3)&1)&"♦"&
MID('grouping project'!A2:A, 8, 5), 'grouping project'!A2:AO},
"select Col1,count(Col3),'Winners #'
where Col1 is not null
and Col3 >= 0
group by Col1
label count(Col3)'','Winners #'''", 0);
QUERY({MONTH(MID('grouping project'!A2:A, 8, 3)&1)&"♦"&
MID('grouping project'!A2:A, 8, 5), 'grouping project'!A2:AO},
"select Col1,count(Col3),'Loosers #'
where Col3 <= 0
and Col1 is not null
group by Col1
label count(Col3)'','Loosers #'''", 0)},
"select Col1,sum(Col2)
group by Col1
pivot Col3
label Col1'Week ending'", 0)), "^.+♦", ),
"where Col1 is not null", 0))
|