1

私はSql Query好きです:

select distinct FROM_EMAILID,FROM_COUNTRY from SURVEY_VISITORS
where FROM_COUNTRY IN 
(
  select top 1 FROM_COUNTRY as FROM_COUNTRY from SURVEY_VISITORS 
  where FROM_COUNTRY<>'undefined' 
  group by FROM_COUNTRY order by COUNT(*) desc
) 

INOperatorで処理できません。
どんな助けでも大歓迎です。

サブクエリについては、次の方法を試しました:

var innerQuery = (from t in VDC.SURVEY_VISITORS
                           group t by new
                           {
                              t.FROM_COUNTRY
                           } into g
                           orderby
                            g.Count() descending
                           select new
                           {
                             VisitorCount = (Int64?)g.Count(),
                             Country = g.Key.FROM_COUNTRY
                           }).FirstOrDefault();
4

1 に答える 1

0
var innerQuery = (from t in VDC.SURVEY_VISITORS
                  group t by new
                  {
                    t.FROM_COUNTRY
                  } into g
                  orderby
                  g.Count() descending
                  select new
                  {
                    VisitorCount = (Int64?)g.Count(),
                    Country = g.Key.FROM_COUNTRY
                  }).FirstOrDefault();

var result = (from xx in VDC.SURVEY_VISITORS
                                  where ((innerQuery.Country.Contains(xx.FROM_COUNTRY)) && xx.TEMPLATE_ID == RecentBlastedTemplate.TEMPLATE_ID)                                  
                                  select new
                                      {
                                          xx.FROM_COUNTRY,
                                          xx.FROM_EMAILID
                                      }).Distinct().ToList();
于 2013-09-24T07:46:03.310 に答える