日期:2014-05-18 浏览次数:20481 次
select t1.key1,t1.namekey,t2.amt from (select Min(key1) as key1,namekey from Table1 group by namekey) t1,(select namekey,sum(amt) as amt from Table1 group by namekey) as t2 where t1.namekey=t2.namekey order by key1
------解决方案--------------------
ArrayList里边放的是什么东西?
12 221 用什么形式放在里边的?
------解决方案--------------------
int[] A = { 12, 13, 14, 15, 16 };
int[] B = { 221, 221, 224, 225, 224 };
ArrayList AB = new ArrayList();
AB.Add(A);
AB.Add(B);
Hashtable temp = new Hashtable();
for (int iRows = 0; iRows < B.Length; iRows++)
{
string BKey = B[iRows].ToString();
if (temp[BKey] != null)
{
temp[BKey] += ",";
}
temp[BKey] += A[iRows].ToString();
}
foreach (DictionaryEntry deTemp in temp)
{
Response.Write("A:" + deTemp.Value + "__" + "B:" + deTemp.Key + "<BR>");
}
//A:14,16__B:224
//A:15__B:225
//A:12,13__B:221
------解决方案--------------------
key1 namekey amt
1 221 5
2 222 5
3 223 5
4 221 5
5 223 5
6 224 5
现在要查出key1,namekey,amt条件 namekey相同时 取---- key1 任一一值或指定一值(如221 取key1 1或4),amt 总值相加
key1 namekey amt
1 221 10
2 222 5
3 223 10
6 224 5
--------------------------
select (select top 1 key1 from T1 where namekey = A.namekey),
A.namekey,
sum(A.amt)
from T1 A
group by A.namekey