SQL最终查询
现在
select a from table_a where aa=123
select b from table_a where aa=32
select sum(aa) as c from table_a where aa=44
select sum(bb) as d from table_a where aa=88
现在要把四句之用一句来替代,实现查询结果类似下面的,不是用union实现的简单连接,要结果中有这四个字段,用union的话就只有一个字段了
a b c d
1 2 32 32
23 43 54 564
32 43 64 45
加个自增列 left join
米看懂需求
需求不明
逻辑不清
表结构和实际数据没有,,,,没法
绑定了 最近老有这种我难题
表结构和原始数据呢??
相关问答:
大家帮忙看看这2个sql语句哪个查询的速度更快点。谢谢帮忙。比较着急。在做性能测试。
select * from
表A LEFT OUTER JOIN 表B ON (表A.id || ' ' =表B.id) ,表C , 表D, 表E
Where其他条件
select * ......
--drop table #T1
--drop table #T2
create Table #T1(ID int,
QueryID nvarchar(20),
ResultID1 nvarchar(20),
ResultID2 nvarchar(20))
create Table #T2(SortNo int,
QueryID nvarchar(20),
ResultID1 nv ......
今天做了一个存储过程 环境是SQL2000数据库
大致如下
建立临时表
定义员工游标
循环员工(属于1个公司)
......
protected void btnLogin_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection("Server = (local);user id = sa;pwd = 1;database = Login");
&nb ......
我是在toad中输入下段sql
declare
TYPE test_rec IS record(
code varchar(10),
name varchar(30)
);
v_book test_rec;
......