易截截图软件、单文件、免安装、纯绿色、仅160KB
热门标签: c c# c++ asp asp.net linux php jsp java vb Python Ruby mysql sql access Sqlite sqlserver delphi javascript Oracle ajax wap mssql html css flash flex dreamweaver xml
 最新文章 : sql

SQL查询每所学校语文成绩最高的学生信息

数据库 有两张表
表1: student
表2:chinese
现在要分别列出 每所学校 语文成绩最高的 学生信息
SQL :
SELECT *
from student
LEFT JOIN chinese ON student.no = chinese.no
WHERE chinese.chengji
IN (
SELECT max( chinese.chengji )
from student
LEFT JOIN chinese ON student.no = chinese.no
GROUP BY student.school
ORDER BY chinese.chengji DESC
)
LIMIT 0 ,30
执行结果:
PS:  SQL 语句也是在学习中。可能写的也不是很好 贴上来方便像我这样的菜鸟借鉴一下 如有更好的方式 希望回复告诉我一下。本人将万分感激。 ......

SQL Server 数据格式修改时,没有保存按钮的情况解决

如果你使用的是 SQL Server 2008, 当你修改数据结构后,保存时会报下图情况: Saving changes is not permitted. The changes you have made require the following tables to be dropped and re-created. You have either made changes to a table that can't be re-created or enabled the option Prevent saving changes that require the table to be re-created. 这是 SQL Server 2008 的一种自我保护,当你的修改可能导致数据表被删除并重新创建时(dropped and re-created),就会有这个提醒。 导致表被重新创建可能是以下几种情况: 在表中间添加一个新列; 删除列 更改列为 Null 性 更改列的顺序 更改列的数据类型 若要不使用这个保护,需要在“工具”菜单中单击“选项”,展开“设计器”,然后单击“表设计器和数据库设计器”。 清除“阻止保存要求重新创建表的更改”复选框。 on the Tools menu, click Options, expand Designers, and then click Table and Database Designers. Select or clear the Prevent saving changes that require the table to be re-created check box. 如下图: 参考资料: Save (Not Permitted) ......

从SQL数据库里随机读取一条记录



怎样从数据库里随机读取
一条记录,
SELECT TOP 1 * from dbo.Customers ORDER BY  NEWID()
这样,如果是随机10
条,100条。。。。
SELECT TOP 10 * from dbo.Customers ORDER BY  NEWID()
很简单吧。
不过top后面数字越大,运行速度越慢。不推荐数据字太大。
以后代码在SQL20005中测试通过,ACCESS好像不行。
......

orale sql相关学习

to_date和to_char是oracle里里面的内置函数而不是标准的sql语法中的函数,用法举例:
1.to_char,返回结果可显示为各种形式
 select to_char(sysdate,'yyyy/mm/dd') ,sysdate from dual;
结果:  2010/05/26                  2010-5-26 17:09:33
2.to_date,转化为DATE型,返回结果形式只有一种
select to_date( '21/01/2002   18:02:23 '   , 'dd/mm/yyyy   hh24:mi:ss' ),to_date( '21/01/2002   8:02:23 '   , 'dd/mm/yyyy   hh:mi:ss PM' ) from dual;
结果: 2002-1-21 18:02:23          2002-1-21 8:02:23
  ......

SQL Server的定序(Collation)

使用SQL Server的朋友們應該都知道SQL Server的資料庫有一個設定叫做定序(Collation),今天我們就來看看定序這東西是什麼,首先我們看一下Wiki上對定序的說明:
Collation is the assembly of written information into a standard order. One common type of collation is called alphabetisation, though collation is not limited to ordering letters of the alphabet. Collating lists of words or names into alphabetical order is the basis of most office filing systems, library catalogs and reference books..[Reference from here.]
這段話講得玄了點,我們看另一個比較易懂的說明:
Collation refers to a set of rules that determine how data is sorted and compared. Character data is sorted using rules that define the correct character sequence, with options for specifying case-sensitivity, accent marks, kana character types and character width.[Reference from here.]
這段 ......

JDBC调用Sql server 2005 存储过程出现的问题

环境:JDK1.5
数据库:Sql server 2005 +sp2
JDBC驱动:sqljdbc.jar
测试类代码如下:
import java.sql.*;
public class test {
 /**
  * @param args
  * @throws SQLException
  * @throws ClassNotFoundException
  */
 public static void main(String[] args) throws SQLException, ClassNotFoundException {
  Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
  Connection con = DriverManager.getConnection("jdbc:sqlserver://192.168.1.168:1433;SelectMethod=cursor;DatabaseName=DBName", "sa", "sa");
  
  //PreparedStatement ps = con.prepareCall("exec Proc_checkPDDateTime '00','00'");  --使用PreparedStatement也可以
  CallableStatement ps = con.prepareCall("{call dbo.Proc_checkPDDateTime('1602327','20100526162514')}");
  
  //{第一种方式}  两种方式调用存储过程的返回值都可以
//  ResultSet rs= ps.executeQuery();
//  if(rs.next()){
//  &n ......
总记录数:4346; 总页数:725; 每页6 条; 首页 上一页 [22] [23] [24] [25] 26 [27] [28] [29] [30] [31]  下一页 尾页
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号