select * from a where a1(select * from a where ...)
刚才的错了!更正为:select * from a where a1 in (select * from a where ...)
select * from (select * from table where tid>1) as aaa where ....
你可以使用Filter属性或Locate方法,具体要看你需要的效果是什么样的
我用了3个TQUERY控件,前两个TQUERY控件是交叉表查询出结果,第三个TQUERY控件要SELECT前两个交叉表的结果。 用select * from (select * from table where tid>1) as aaa where ....的话,(select * from table where tid>1)好象不能是交叉查询,必须要建立两个临时表。我的思路正确吗?还有更好的方法没呢?
用select * from (select * from table where tid>1) as aaa where ....的话,(select * from table where tid>1)好象不能是交叉查询,必须要建立两个临时表。谁说的? Select * from ( Select a.ID, a.Name from ( Select a.ID, b.Name from a Left join b on a.id = b.id ) a ) b
我说的交叉查询是交叉表: TRANSFORM Sum(A.面积) AS 面积之总计 SELECT B.分公司名称 AS 统计单位, A.验收树种 AS 树种, Sum(A.小班面积) AS 总面积 FROM A INNER JOIN B ON A.编号 = B.编号 GROUP BY B.分公司名称, A.验收树种 PIVOT A.造林模式;
用过滤设置filter ' name='...
sql 自己就可以嵌套查询啊?
Select * from (SELECT B.分公司名称 AS 统计单位, A.验收树种 AS 树种, Sum(A.小班面积) AS 总面积 FROM A INNER JOIN B ON A.编号 = B.编号 GROUP BY B.分公司名称, A.验收树种) b where Conditions
ADOQuery有个filter属性,看一下帮助^_^
drop table a2 creat table a2 as select * from a1 where id=456 select * from a2 where id=456
select * from 表名 where 字段 in (select * from 表名B where ...)用SELECT的子查询就可以了
select * from a where a1(select * from a where ...)
用表变量或者临时表 --表变量 Declare @T table(a int,b int) insert into @t select a1 ,a2 from tablename where ...select * from @t where ...再或者直接在原先的sql上加条件限制
用select * from (select * from table where tid>1) as aaa where ....的话,(select * from table where tid>1)好象不能是交叉查询,必须要建立两个临时表。我的思路正确吗?还有更好的方法没呢?
Select * from (
Select a.ID, a.Name from (
Select a.ID, b.Name from a Left join b on a.id = b.id
) a
) b
TRANSFORM Sum(A.面积) AS 面积之总计
SELECT B.分公司名称 AS 统计单位, A.验收树种 AS 树种, Sum(A.小班面积) AS 总面积
FROM A INNER JOIN B ON A.编号 = B.编号
GROUP BY B.分公司名称, A.验收树种
PIVOT A.造林模式;
' name='...
FROM A INNER JOIN B ON A.编号 = B.编号
GROUP BY B.分公司名称, A.验收树种) b
where Conditions
creat table a2 as select * from a1 where id=456
select * from a2 where id=456
--表变量
Declare @T table(a int,b int)
insert into @t
select a1 ,a2 from tablename where ...select * from @t where ...再或者直接在原先的sql上加条件限制
Create table #T
..//用法同表变量
我用Grid++里面提供的方法做的交叉表,只要Select要的数据,再在报表里面处理成交叉表。
再次感谢大家!~~~~~~~