如何从表中一列上的一行中只选择一个单元格? [英] How do you select just one cell from one row on one column in a table?

查看:100
本文介绍了如何从表中一列上的一行中只选择一个单元格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以这就是我要做的事情。 目标是生成临时表,其中列的编号为1到10.
$
以下sql语句生成所需内容的数据的部分:

So this is what I am tryng to do.  The goal is to produce a temp table where the columns are numbered 1 to 10.
The following sql statements produces PART of the data that is required content:

  选择Count(*)作为_Count,来自CompDiffTable的RuleName 按照RuleName顺序分组_Count desc

  选择Count(*)作为_Count,RuleName  INTO #DATA_DrillReport来自CompDiffTable group by RuleName order by _Count desc

   select Count(*) as _Count,RuleName from CompDiffTable  group by RuleName order by _Count desc
   select Count(*) as _Count,RuleName  INTO #DATA_DrillReport from CompDiffTable group by RuleName order by _Count desc

   SELECT  * FROM#DATA_DrillReport 按_Count desc订购

   SELECT  * FROM #DATA_DrillReport  order by _Count desc

   DROP TABLE #DATA_DrillReport

  

这会创建一个有序的表,其中一列RuleNames按照我的方式排序希望。

现在,让我们假设其中一个规则名称是GIZANTHAPUS(它不是,但我们只是说它是。) 


因此,当我测试获取与GIZANTHAPUS相关联的FileID时,我尝试了这个错误的SQL查询:

   DROP TABLE #DATA_DrillReport
  
This creates an ordered table where a column of RuleNames ordered the way I want.
Now, lets suppose one of those rule names is GIZANTHAPUS (it is not, but let's just say it is). 
So, as I test to get a FileID associated with GIZANTHAPUS, I tried this mishapen SQL query:

  SELECT  FILEID   FROM CompDiffTable,其中RuleName =" GIZANTHAPUS"

 

语法错误,但您明白了。 

它应该返回一个FileId列表,其中RuleName是GIZANTHAPUS

这个测试是试图创建一个查询,其中"GIZANTHAPUS"被替换为第一个查询中重复RuleName的变量。

我在最终临时表中真正想要的是与RuleNames相关联的所有FileId。 这是最终临时表的内容。

 SELECT  FileId   FROM CompDiffTable where RuleName = "GIZANTHAPUS"
 
The syntax is wrong, but you get the idea. 
It should have returned a list of FileId's where the RuleName is GIZANTHAPUS
This test was an attempt to step towards createing a query where "GIZANTHAPUS" is replaced by a variable repesenting the RuleName from the first query.
What I really want in the final temp table is all the FileId's that are associated with the RuleNames.  That is the content of the final temp table.

我希望我的最终临时表包含数据,其中查询的RuleNames按列顺序显示为查询中的行:

I want my final temp table to contain data where the queried RuleNames are are in the column order that they would appear as rows in the query:

   SELECT  * FROM#DATA_DrillReport 按_Count desc排序

  SELECT  * FROM #DATA_DrillReport  order by _Count desc

并且行将包含与该RuleName关联的FileID。  

And the rows would contain the FileID's associated that with that RuleName.  



  ;我已经看到一个select语句,它生成一个表,实际上每个列都有嵌套的select语句。 我认为这就是我需要做的事情。 这张图显示了这样一个select语句,其中临时表的每一列都由
自己的select语句组成。 这就是我想要做的。 我认为我现在唯一缺少的是如何使每个嵌套的select语句只查询我在RuleName列下创建的第一个表的一行。 这张图片只是
这个嵌套选择模式的一个示例,现在代表我的查询将会是什么样子 


 I have seen a select statement that produces a table actually have nested select statement for each column.  This, I think is what I need to do.  This picture shows such a select statement where each column of the temporary table is made by its own select statement.  This is what I want to do.  The only thing I think I am missing now is how to make each of these nested select statements query just ONE row of the first table I made under the column for RuleName.  This pic is just an example of this nested select pattern and now representative of what my query will look like 

推荐答案

美好的一天Bobby,

Good day Bobby,

您能否向我们提供完整的样本,而不仅仅是一般性描述

Can you provide us the full sample and not just general description


这篇关于如何从表中一列上的一行中只选择一个单元格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆