求问一SQL语句
客户表:
客户编号 客户销售总额
aa 200
bb 300
cc 400
客户联系表:
客户编号 联系日期 联系内容
aa 2009/01/01 111
bb 2009/02/01 222
aa 2009/03/01 333
aa 2009/04/01 444
bb 2009/05/01 555
要求结果:
客户编号 销售总额 最近联系日期 联系内容
aa 200 2009/04/01 444
bb 300 2009/05/01 555
cc 400
SQL code:
select a.客户编号,a.客户销售总额,b.联系日期,联系内容
from 客户表 a
left join 客户联系表 b
on a.客户编号=b.客户编号
and not exists(select 1 from 客户联系表 where 客户编号=b.客户编号 and 最近联系日期>b.最近联系日期)
SQL code
Code highlighting produced by Actipr
相关问答:
直接在sql语句中写:
sql= " declare @1 nvarchar(max),@2 nvarchar(max)...... "
然后
Rs.open sql,CONN,3,2
Response.Write Rs.recordcount
但是没有打开,报错
ADODB.Records ......
自从直接在一个表里加了个字段(nvarchar 其他默认,不插入自己默认为 <null>)后,重启网站+sql server 2000 6-8个小时后出现问题:网站写数据库时脚本超时
Active Server Pages 错误 'ASP 0113 ......
我安装SQL SERVER2008的时候选择WINDOWS身份验证连接的,我不知道怎么写连接。。。
还有我想改成SQL SERVER身份验证怎么改??
谢谢大家了!
XML code:
<configuration>
<appSettings>
& ......
import java.sql.*;
public class Test {
public static void main(String[] srg) {
String driverName = "com.microsoft.sqlserver.jdbc.SQLServerDriver"; //加载JDBC ......
StringBuffer str = new StringBuffer("select * from menu where parentid=1 and mid <>1 order by parentid");
List list = new ArrayList();
ResultSet rst = null;
DataBa ......