sql匹配查询排序
表A中有Address,Aname,Asex三个字段
insert into a values('上海','张三','男')
insert into a values('北京','李四','女')
insert into a values('深圳','王五','男')
insert into a values('上海','赵六','女')
insert into a values('北京','陈七','男')
insert into a values('上海','张三','男')
...
查询所有结果,地址最多的排第一,姓名排第二,性别第三,输出结果
Address Aname Asex
上海 张三 男
上海 张三 男
上海 赵六 女
北京 ....
....
请教如何实现?
SQL code:
select Address,Aname,Asex
from 表A t
order by (select count(*) from 表A where Aname= t.Aname) desc,Aname
SQL code:
select *
from ta a
order by isnull((select count(*) from ta where Address=a.Address),0)desc,
isnull((select count(*) from ta where Aname=a.Aname),0)desc,
isnull((select count(*) from ta where Asex=a.Asex),0)desc
SQL code
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www
相关问答:
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jas ......
场景如下:
客户把备份好的数据库,发给我,我在本机还原后,运行写好的存储过程,比较快,并且在实施那边运行同样比较快。但是当实施在客户那边运行的时候速度就非常的慢,时间超出了程序的时间限制。远程在客户那 ......
一、7|3|1,8|6|1,3|1|1,16|1|1,5|7|1,9|7|1
二、6|3|1,7|3|1,8|6|1,2|1|1,3|1|1,16|1|1,4|7|1,5|7|1,9|7|1,10|7|1,11|4|1,12|4|1,13|4|1,14|5|1,15|5|1,17|0|1
怎样查询 一 在 二 里面并输出记录集。
SQL code: ......
protected void btnLogin_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection("Server = (local);user id = sa;pwd = 1;database = Login");
&nb ......