⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 requete2.sql

📁 a small application in Mysql and Delphi
💻 SQL
字号:

CREATE  PROCEDURE  requete2()
BEGIN
CREATE VIEW  nbre_emprunt ( code_personne,nbre_emrp)  AS
SELECT  p.code_personne,count(*)  
 FROM emprunt e,personne p
 WHERE e.code_personne=p.code_personne
 GROUP BY code_personne;
CREATE VIEW duree (code_personne,duree_minimale, duree_moyenne,duree_maximale)AS
SELECT  e.code_personne,IF( date_restitution IS NOT NULL, 
 MIN(DATEDIFF(date_restitution,date_emprunt) ), 
MIN( DATEDIFF(current_date ,date_emprunt )
              )) AS duree_minimale,
IF( date_restitution IS NOT NULL, 
 AVG(DATEDIFF(date_restitution,date_emprunt) ), 
AVG( DATEDIFF(current_date ,date_emprunt )
              )) AS duree_moyenne,			  
IF( date_restitution IS NOT NULL, 			  
MAX(DATEDIFF(date_restitution,date_emprunt) ), 
MAX( DATEDIFF(current_date ,date_emprunt )
              )) AS duree_maximale		
FROM emprunt e,personne p
WHERE e.code_personne=p.code_personne
GROUP BY code_personne;
SELECT  * FROM  nbre_emprunt NATURAL JOIN duree ;
drop view nbre_emprunt;
drop view duree ;
END/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -