我有这个查询:
select a.name, count(distinct numClient)
from a
group by a.name;
我想添加另一列,该列将为每行计数前几行的总和:
JONES 3 0
SMITH 5 3
JOHN 10 8
.....
KEN 12 365
可以帮忙吗?我想我必须使用分区,但是对它的理解不太清楚。
答案 0 :(得分:2)
您根本不需要子查询:
#include<stdint.h>
#include<stdlib.h>
#include<stdio.h>
void test(uintptr_t *data)
{
unsigned char raw_data[] = "this is a test data";
unsigned char *raw = (unsigned char*)malloc(strlen((char*)raw_data));
memcpy(raw, raw_data, strlen((char*)raw_data)+1);
*data = (uintptr_t)raw;
}
int main(int argc, char* argv[])
{
uintptr_t data;
test(&data);
printf("%s\n", (char *)data);
if ((void *)data != NULL)
{
free((void *)data);
}
return 0;
}
答案 1 :(得分:0)
假设有一列指定计算累积总和的顺序,则可以使用
string checkrole = "select RName from [account] where username= '" + TextBoxUser.Text + "'";
SqlCommand roleCom = new SqlCommand(checkrole, con);
string role = roleCom.ExecuteScalar().ToString();
if (role == "Teacher")
{
Session["New"] = TextBoxUser.Text;
Session["Username"] = TextBoxUser.Text;
Response.Redirect("HomeTeacher.aspx");
}
else
{
Response.Redirect("HomeParent.aspx");
}