美好的一天,
我想选择一个平均字段
的表格SELECT
CAST(SurveyDept AS NVARCHAR(100)) as Dept_name,
CAST(SurveySubDept AS NVARCHAR(100)) as Subdept_name
AVG(SurveyReachability) as total_R,
AVG(SurveyProfessionalism) as total_P,
AVG(SurveyProactiveness) as total_Pr,
AVG(SurveyCompetence) as total_C,
AVG(SurveyResponse) as total_Re
FROM
dbo.tb_SurveyDeptInfo
GROUP BY
CAST(SurveyDept AS NVARCHAR(100)),
CAST(SurveySubDept AS NVARCHAR(100))
ORDER BY
CAST(SurveyDept AS NVARCHAR(100)),
CAST(SurveySubDept AS NVARCHAR(100))
结果如下:
我想要做的是将“子部门名称”排除在值(转移)和价值(检查和公用事业服务付款)(如果存在)
所以我在(order by)之后添加了以下内容:
WHERE Subdept_name NOT IN (SELECT *
FROM dbo.tb_SurveyDeptInfo
WHERE CAST(SurveySubDept AS NVARCHAR(100)) = 'Transfers'
OR CAST(SurveySubDept AS NVARCHAR(100)) = 'Check & Utility Service Payments')
你能告诉问题在哪里,它没有返回任何记录
答案 0 :(得分:2)
只需将beforeToHtml
子句添加到整个查询中:
public function beforeToHtml(\Magento\Catalog\Block\Product\View\Description $originalBlock)
{
$originalBlock->setTemplate('Vendorname_Modulename::description.phtml');
}
您的查询无效,因为您有WHERE
。子查询返回多个列,因此会出错。
我不明白你为什么要向SELECT CAST(SurveyDept AS NVARCHAR(100)) as Dept_name,
CAST(SurveySubDept AS NVARCHAR(100)) as Subdept_name
AVG( SurveyReachability ) as total_R,
AVG( SurveyProfessionalism ) as total_P,
AVG( SurveyProactiveness ) as total_Pr,
AVG( SurveyCompetence ) as total_C,
AVG( SurveyResponse ) as total_Re
FROM dbo.tb_SurveyDeptInfo
WHERE CAST(SurveySubDept AS NVARCHAR(100)) NOT IN ('Transfers', 'Check & Utility Service Payments')
GROUP BY CAST(SurveyDept AS NVARCHAR(100)), CAST(SurveySubDept AS NVARCHAR(100))
ORDER BY CAST(SurveyDept AS NVARCHAR(100)),CAST( SurveySubDept AS NVARCHAR(100));
做明确的案件。这些似乎只是混乱了查询。我会尝试:
IN (SELECT * . . )
答案 1 :(得分:0)
试试这个
[DisplayName("JSON Extraction Rule")]
[Description("Extracts the specified JSON value from an object.")]
public class JsonExtractionRule : ExtractionRule
{
[DisplayName("Name/path of attribute")]
[Description("String to fetch the attribute from the Json Object.")]
public string Name { get; set; }
[DisplayName("Fetch 4 first characters only")]
[Description("Set to true if only the first 4 characters of the attribute should be fetched.")]
public Boolean fourFirstCharacters { get; set; }
public override void Extract(object sender, ExtractionEventArgs e)
{
if (e.Response.BodyString != null)
{
var json = e.Response.BodyString;
if (json.StartsWith("["))
{
json = "{\"array\":" + json + "}";
}
var data = JObject.Parse(json);
if (data != null)
{
var attribute = data.SelectToken(Name).ToString();
if (fourFirstCharacters)
{
e.WebTest.Context.Add(this.ContextParameterName, attribute.Substring(0, 4));
} else
{
e.WebTest.Context.Add(this.ContextParameterName, attribute);
}
e.Success = true;
return;
}
}
e.Success = false;
e.Message = String.Format(CultureInfo.CurrentCulture, "Not Found: {0}", Name);
}
}