易截截图软件、单文件、免安装、纯绿色、仅160KB

SQL练习

father表   son表    
fid fname   sid sname fid height money
1 a   100 s1 1 1.7 7000
2 b   101 s2 2 1.6 8000
3 c   102 s3 2 1.8 9000s
create table father(
fid number primary key,
fname varchar(10)
);
create table son(
sid number primary key,
sname varchar(10),
fid number,
height number,
money number
);
select t.*, t.rowid from father t;
select t.*, t.rowid from son t;
1、查询sid、sname、fid  
select sid,sname,fid from son;
     
2、查询各儿子涨价20%以后的新学费,注意,8000块以下的不涨价。
select money*1.2 as new_money from son where money>=8000
union all
select money from son where money<8000;
select '涨了' as 涨价情况,money*1.2 as new_money from son where money>=8000
union all
select '没涨',money from son where money<8000;
select money,money*1.2 as new_money from son where money>=8000
union all
select money,null from son where money<8000;
select son.*,(case when money<8000 then money
               when money>=8000 then money*1.2 end)as new_money
from son;
              
--函数
create or replace function f_get_new_money(p_money son.money%type)
return number
as
begin
  if(p_money>=8000)then
    return p_money*1.2;
  else
    return p_money;
  end if;
end;
select son.*,scott.f_get_new_money(money) as new_money from son;
--一题多解,下面的题目也是按照这种思路(1.用SQL 2.如果做不来,用函数一定可以)
     
3、查询sid、sname、fname。  
--语法  from t1 join t2 on t1.id=t2.id
SELECT s.sid,s.sname,f.fname
from father f JOIN son s ON f.fid=s.fid; 


相关文档:

SQL2005和(Excel |access)之间的数据导入导出


Sql代码
--采用SQL语句实现sql2005和Excel 数据之间的数据导入导出,在网上找来一--下,实现方法是这样的:    
  
  
--Excel---->SQL2005  导入:    
  
  
select * into useinfo from O ......

[收拢] 用sqlite 执行标准 sql 语法

http://www.umgr.com/blog/PostView.aspx?bpId=36294
 1. 执行sql语句
int sqlite3_exec(sqlite3*, const char *sql, sqlite3_callbacksql 语法
, void *,  char **errmsg );
这就是执行一条 sql 语句的函数。
第1个参数不再说了,是前面open函数得到的指针。说了是关键数据结构。
第2个参数const char ......

SQL Server 2005 与 SQL Express 的异同


SQL Server Express 2005(以下简称 SQLExpress) 是由微软公司开发的 SQL Server 2005(以下简称 SQL2005)的缩减版,这个版本是免费的,它继承了 SQL Server 2005 的多数功能与特性,如:安全性设置、自定义函数和过程、Transact-SQL、SQL、CLR 等,还免费提供了和它配套的管理软件 SQL Server Management Studio Expre ......

sql 分页技术

分页语句
sqlserver 方案1: select top 10 * from t where id not in(select top 30 id from t order by id) order by id
方案2: select top 10 * from t where id in (select top 40 id from t order by id)oder by id desc
mysql: select * from t order by id limit 30,10
oracle: select * from (select rownu ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号