SQL:
SELECT i.name, l.city, COUNT( l.city ) AS num
FROM locality l
JOIN event e ON e.ID_locality = l.ID
JOIN program p ON p.ID_event = e.ID
JOIN interpreter i ON i.ID = p.ID_interpreter
WHERE i.name = 'XXXX'
GROUP BY l.city
HAVING COUNT( l.city) = (
SELECT MAX( num )
FROM ( SELECT COUNT( city ) AS num
FROM (SELECT l.city FROM locality l
JOIN event e ON e.ID_locality = l.ID
JOIN program p ON p.ID_event = e.id
JOIN interpreter i ON i.ID = p.ID_interpreter
WHERE i.name = 'XXXX'
GROUP BY l.city) tmp ) tmp2)
林克:
var q4 = from l in db.locality
join e in db.event on l.ID equals e.ID_locality
join p in db.program on e.ID equals p.ID_event
join i in db.interpreter on p.ID_interpreter equals i.ID
where i.name == "XXXX"
group l by l.city into grp
你好,我对 LINQ 中的这个选择有严重的问题。我用 SQL 编写了这个选择,但我不知道如何通过计数来使用多子选择和组......我想选择解释器“XXXX”最常行动的城市以及解释器在那里行动的次数。我还在这里检查了输入链接描述,但是当我尝试使用它时它没有帮助我。如果有人可以帮助我,我会很高兴。为了更好的定位: