blob_id stringlengths 40 40 | language stringclasses 1
value | repo_name stringlengths 5 133 | path stringlengths 3 276 | src_encoding stringclasses 33
values | length_bytes int64 23 9.61M | score float64 2.52 5.28 | int_score int64 3 5 | detected_licenses listlengths 0 44 | license_type stringclasses 2
values | text stringlengths 23 9.43M | download_success bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|
48949571148160b43714da9981a8be4e71ae1ff5 | SQL | pinardy/Booklink | /sql_codes.sql | UTF-8 | 2,959 | 4 | 4 | [] | no_license | # Find "# Check" to find the positions that needs to be checked
# Find "# TODO" to find work undone
# Check how should we store the id? Should we use CHAR or INT, currently it uses VARCHAR
# VARCHAR is more efficient if there is no need for numeric operations
# TODO implementation of cardinality within the script
# CHECK field variable types
USE projecttest;
# Entities
# create the book table
CREATE TABLE book (
title TINYTEXT NOT NULL,
cover_format TINYTEXT CHECK(cover_format="paperback" or cover_format="hardcover"),
num_pages INT,
authors TINYTEXT,
publisher TINYTEXT,
year_publish YEAR,
edition INT,
ISBN10 CHAR(10) NOT NULL,
ISBN13 CHAR(13) NOT NULL,
PRIMARY KEY (ISBN13)
);
# creates the user account
CREATE TABLE user_account (
user_id VARCHAR(20),
login_name VARCHAR(20) UNIQUE,
user_password VARCHAR(20) NOT NULL,
PRIMARY KEY (user_id)
);
# Order and Purchases combined into 1 table
CREATE TABLE purchase_history (
purchase_id VARCHAR(20),
user_id VARCHAR(20) NOT NULL,
ISBN13 CHAR(13) NOT NULL,
no_copies INT CHECK (no_copies > 0),
order_date DATE NOT NULL, # check do we need this?
PRIMARY KEY (purchase_id),
FOREIGN KEY (user_id) REFERENCES user_account(user_id),
FOREIGN KEY (ISBN13) REFERENCES book (ISBN13)
);
# Keeps track of the number of copies
CREATE TABLE inventory(
ISBN13 CHAR(13),
no_copies INT CHECK (no_copies > 0),
PRIMARY KEY (ISBN13),
FOREIGN KEY (ISBN13) REFERENCES book (ISBN13) ON DELETE CASCADE
);
# Feedback for the Book
# Check do we need a feedback_id, could we use user_id,ISBN13 as the key instead? JJJ - I am more in favour of using user_id,ISBN13
CREATE TABLE feedback (
feedback_user VARCHAR(20),
ISBN13 CHAR(13),
entry_date DATE NOT NULL,
score INT CHECK (score >=0 AND score <= 10),
feedback TINYTEXT,
PRIMARY KEY (feedback_user,ISBN13),
FOREIGN KEY (feedback_user) REFERENCES user_account(user_id) ON DELETE CASCADE,
FOREIGN KEY (ISBN13) REFERENCES book (ISBN13) ON DELETE CASCADE
);
# Rating for the Feedback
# Check do we need a rating_id, could we use feedback_id,user_id as the key instead? JJJ - I am more in favour of using feedback_user,rating_user,ISBN13
CREATE TABLE rating (
rating_user VARCHAR(20),
feedback_user VARCHAR(20),
ISBN13 CHAR(13),
entry_date DATE NOT NULL, # CHECK do we need this?
score INT CHECK (score >=0 AND score <= 2),
PRIMARY KEY (feedback_user,rating_user,ISBN13),
FOREIGN KEY (rating_user) REFERENCES user_account(user_id) ON DELETE CASCADE,
FOREIGN KEY (feedback_user) REFERENCES feedback (feedback_user) ON DELETE CASCADE,
FOREIGN KEY (ISBN13) REFERENCES book (ISBN13) ON DELETE CASCADE
);
CREATE TRIGGER UpdateInventory
AFTER INSERT on purchase_history
FOR EACH Row
UPDATE inventory
SET inventory.no_copies = inventory.no_copies - NEW.no_copies
WHERE inventory.ISBN13 = NEW.ISBN13;
# TODO create triggers
| true |
952da7a228c49a48ebcffeaf56ae5902b8e02b80 | SQL | rsanttos/bancodedados-sql | /Questão_01-4.sql | UTF-8 | 206 | 3.75 | 4 | [] | no_license | SELECT e.fname, e.minit, e.lname FROM company.employee e
INNER JOIN company.works_on wo
ON e.ssn = wo.essn
GROUP BY e.ssn
HAVING count(e.ssn) = (SELECT COUNT(DISTINCT p.pnumber) FROM company.project p); | true |
1005103f280d8f2110e363f36037e31530d25f8e | SQL | landpeople/landpeople | /Scripts/sketchbook.sql | UTF-8 | 5,533 | 4.03125 | 4 | [] | no_license | -- 스케치북 관련 쿼리
CREATE TABLE LPSKETCHBOOK(
SKETCH_ID VARCHAR2(20),
USER_EMAIL VARCHAR2(50),
SKETCH_TITLE VARCHAR2(50),
SKETCH_THEME VARCHAR2(20),
SKETCH_SHARE CHAR(1),
SKETCH_DELFLAG CHAR(1),
SKETCH_BLOCK CHAR(1),
SKETCH_SPATH VARCHAR2(100),
);
CREATE TABLE LPUSER(
USER_EMAIL VARCHAR2(50) NOT NULL,
USER_PASSWORD VARCHAR2(100) NOT NULL,
USER_NICKNAME VARCHAR2(20) NOT NULL,
USER_AUTH CHAR(1),
USER_DELFLAG CHAR(1) DEFAULT 'F',
USER_EMAILCHK CHAR(1),
USER_EMAILKEY VARCHAR2(300),
USER_ISWRITE CHAR(1) DEFAULT 'T'
);
CREATE TABLE LPCOLLECT(
COL_ID VARCHAR2(20),
USER_EMAIL VARCHAR2(50),
SKETCH_ID VARCHAR2(20),
COL_SCRAPE CHAR(1),
COL_LIKE CHAR(1)
);
-- 스케치북 작성 O
-- 스케치북 생성 - 스케치북 테이블(LPSKETCHBOOK) 입력
SELECT USER_ISWRITE FROM LPUSER WHERE USER_EMAIL = '128@happy.com';
INSERT INTO LPSKETCHBOOK
(SKETCH_ID, USER_EMAIL, SKETCH_TITLE, SKETCH_THEME,
SKETCH_SHARE, SKETCH_DELFLAG, SKETCH_SPATH, SKETCH_BLOCK)
VALUES('0012', '130@happy.com','여행타이틀', '나홀로', 'F', 'F', 'c:\abc\dedf', 'F');
-- 스케치북 수정
-- 스케치북 정보 수정 O (사용자-마이페이지)
UPDATE LPSKETCHBOOK SET SKETCH_TITLE='제목~!@!#@@#', SKETCH_THEME='가족여행', SKETCH_SHARE='Y', SKETCH_SPATH='c:\abbb\cccc'
WHERE USER_EMAIL='123@happy.com' AND SKETCH_ID='0001';
-- 스케치북 스크랩 수정(취소, 삭제)
UPDATE LPCOLLECT SET COL_SCRAPE='F' WHERE USER_EMAIL='128@happy.com' AND SKETCH_ID='0006';
-- 스케치북 '좋아요' (취소, 삭제)
SELECT COL_LIKE FROM LPCOLLECT WHERE USER_EMAIL='128@happy.com' AND SKETCH_ID='0006';
UPDATE LPCOLLECT SET COL_LIKE='F' WHERE USER_EMAIL='128@happy.com' AND SKETCH_ID='0008';
-- 스케치북 조회
-- 스케치북 테마별 조회
-- 총 좋아요 수가 표시
SELECT (SKETCH_TITLE, SKETCH_CONTENT, SKETCH_SPATH, (SELECT COUNT(*) CNT FROM LPCOLLECT WHERE SKETCH_ID ='0001') LPLIKE FROM LPSKETCHBOOK WHERE SKETCH_THEME='나홀로') FROM LPSKETCHBOOK WHERE ROWNUM <=9;
-- 스케치북 테마별 조회 무한스크롤 3*3
SELECT SKETCH_ID, SKETCH_TITLE, SKETCH_SPATH
FROM (SELECT ROWNUM RNUM, SKETCH_ID, SKETCH_TITLE, SKETCH_SPATH
FROM (SELECT SKETCH_ID, SKETCH_TITLE, SKETCH_SPATH
FROM LPSKETCHBOOK
WHERE SKETCH_THEME='나홀로' AND SKETCH_SHARE='T' AND SKETCH_DELFLAG='F'AND SKETCH_BLOCK='F'
ORDER BY SKETCH_ID DESC)
)
WHERE RNUM BETWEEN 1 AND 9;
--SELECT COUNT(*) CNT FROM LPCOLLECT WHERE COL_LIKE='T';
SELECT COUNT(*) CNT
FROM LPCOLLECT WHERE SKETCH_ID= '0006' AND COL_LIKE='T';
SELECT COUNT(*) CNT FROM LPCOLLECT, LPSKETCHBOOK WHERE LPSKETCHBOOK.USER_EMAIL='128@happy.com' AND LPCOLLECT.SKETCH_ID= LPSKETCHBOOK.SKETCH_ID AND COL_LIKE='T';
-- 마이페이지에서는 세션에서 사용자 이메일 받아옴 테마별 스케치북 조회 사용자 이메일 ????
-- 스케치북 조회(사용자-마이페이지) O
SELECT SKETCH_ID, SKETCH_TITLE, SKETCH_SPATH
FROM (SELECT ROWNUM RNUM, SKETCH_ID, SKETCH_TITLE, SKETCH_SPATH
FROM (SELECT SKETCH_ID, SKETCH_TITLE, SKETCH_SPATH
FROM LPSKETCHBOOK
WHERE USER_EMAIL='124@happy.com' AND SKETCH_DELFLAG='F' AND SKETCH_BLOCK='F'
ORDER BY SKETCH_ID DESC)
)
WHERE RNUM BETWEEN 1 AND 9;
SELECT COUNT(*) CNT
FROM LPCOLLECT WHERE SKETCH_ID= '' AND COL_LIKE='T';
-- 마이페이지에서는 세션에서 사용자 이메일 받아옴
-- 스크랩한 스케치북 조회
SELECT LPSKETCHBOOK.SKETCH_ID, SKETCH_THEME, SKETCH_TITLE, SKETCH_SHARE, SKETCH_SPATH FROM LPSKETCHBOOK, LPCOLLECT WHERE LPCOLLECT.USER_EMAIL='128@happy.com' AND LPSKETCHBOOK.SKETCH_ID = LPCOLLECT.SKETCH_ID AND LPSKETCHBOOK.SKETCH_SHARE='T' AND LPSKETCHBOOK.SKETCH_DELFLAG='F' AND LPSKETCHBOOK.SKETCH_BLOCK='F';
-- 스크랩한 스케치북 갯수 조회
SELECT COUNT(*) CNT FROM LPCOLLECT WHERE USER_EMAIL='128@happy.com' AND COL_SCRAPE='T';
SELECT COUNT(*) CNT FROM LPCOLLECT WHERE SKETCH_ID='0006' AND COL_LIKE = 'T';
/*(SELECT COUNT(*) FROM LPCOLLECT WHERE COL_LIKE='T')LPLIKE*/
-- 스케치북 스크랩 등록, 자신이 작성한 스케치북 스크랩 X
-- 최초 등록
INSERT INTO LPCOLLECT(COL_ID, USER_EMAIL, SKETCH_ID, COL_SCRAPE , COL_LIKE)
SELECT '001','128@happy.com', '0006', 'F', 'F' FROM DUAL WHERE NOT EXISTS(SELECT * FROM LPCOLLECT WHERE USER_EMAIL='128@happy.com' AND SKETCH_ID ='0006');
-- 스케치북 스크랩 등록, 상태 변경
UPDATE LPCOLLECT SET COL_SCRAPE='T' WHERE USER_EMAIL='128@happy.com' AND SKETCH_ID='0006';
-- 스케치북 '좋아요' 등록
-- 좋아요 상태 변경
UPDATE LPCOLLECT SET COL_LIKE='T' WHERE USER_EMAIL='128@happy.com' AND SKETCH_ID='0006';
-- 스케치북 삭제
-- 선택한 스케치북 삭제 O
UPDATE LPSKETCHBOOK SET SKETCH_DELFLAG='T' WHERE SKETCH_DELFLAG='F' AND USER_EMAIL='123@happy.com';
-- 선택한 스케치북 다중 삭제 O
UPDATE LPSKETCHBOOK SET SKETCH_DELFLAG='T' WHERE SKETCH_DELFLAG='F' AND USER_EMAIL IN('123@happy.com','124@happy.com','125@happy.com','126@happy.com','127@happy.com','128@happy.com','129@happy.com');
-- 선택한 스케치북 스크랩 다중 취소
UPDATE LPCOLLECT SET COL_SCRAPE='F' WHERE USER_EMAIL= '128@happy.com' AND SKETCH_ID IN('0006', '0007', '0004');
| true |
5f4e87460b6acb0375bc32d813ff2032a4e9295b | SQL | Z0etrope/FIT3171--Database-SQL | /Tuts/Tut08/week8_sqlbasic_part_b.sql | UTF-8 | 3,491 | 4.15625 | 4 | [] | no_license | SPOOL week8_sqlbasic_part_b_output.txt
/* 1.List all the unit codes, semesters and names of chief examiners for all the units that are
offered in 2020. Order the output by semester then by unit code.
*/
SELECT
o.unitcode,
semester,
stafffname,
stafflname
FROM
uni.offering o
JOIN uni.staff s ON o.chiefexam = s.staffid
WHERE
TO_CHAR(ofyear,'yyyy') = '2020'
ORDER BY
o.unitcode,
semester;
/*2. List all unit codes, unit names and their year and semester of offering. Order the output by
unit code then by offering year and then semester. To display the offering year correctly in
Oracle, you need to use the to_char function. For example, to_char(ofyear,'yyyy').*/
SELECT
u.unitcode,
unitname,
TO_CHAR(ofyear,'YYYY') AS offeringyr,
semester
FROM
uni.unit u
JOIN uni.offering o ON u.unitcode = o.unitcode
ORDER BY
unitcode,
offeringyr,
semester;
/*3.List the unit code, semester, class type (lecture or tutorial), day and time for all units taught
by Windham Ellard in 2020. Sort the list according to the unit code.
*/
SELECT
unitcode,
semester,
cltype,
clday,
TO_CHAR(cltime,'HHAM') AS time
FROM
uni.staff s
JOIN uni.schedclass sc ON s.staffid = sc.staffid
WHERE
stafffname = 'Windham'
AND stafflname = 'Ellard'
AND TO_CHAR(ofyear,'yyyy') = '2020'
ORDER BY
unitcode,
semester,
cltype,
clday,
cltime;
/*4.Create a study statement for Friedrick Geist. A study statement contains unit code, unit
name, semester and year the study was attempted, the mark and grade. If the mark and
grade is unknown, show the mark and grade as ‘N/A’. Sort the list by year, then by semester
and unit code*/
SELECT
e.unitcode,
unitname,
semester,
TO_CHAR(ofyear,'yyyy') AS "YEAR OF ENROLMENT",
mark,
grade
FROM
uni.student s
JOIN uni.enrolment e ON s.studid = e.studid
JOIN uni.unit u ON e.unitcode = u.unitcode
WHERE
studfname = 'Friedrick'
AND studlname = 'Geist'
ORDER BY
"YEAR OF ENROLMENT",
semester,
unitcode;
/*5. .List the unit code and unit name of the prerequisite units of the 'Introduction to data science'
unit. Order the output by prerequisite unit code*/
SELECT
has_prereq_of AS prereqUnitcode,
u2.unitname AS prereqUnitname
FROM
uni.unit u1
JOIN uni.prereq p ON u1.unitcode = p.unitcode
JOIN uni.unit u2 ON u2.unitcode = p.has_prereq_of
WHERE
u1.unitname = 'Introduction to data science'
ORDER BY
prereqUnitcode;
/*6.Find all students (list their id, firstname and surname) who have received an HD for FIT2094
in semester 2 of 2019. Sort the list by student id.*/
SELECT DISTINCT
s.studid,
studlname,
studfname
FROM
uni.student s
JOIN uni.enrolment e ON s.studid = e.studid
WHERE
mark > 80
AND TO_CHAR(ofyear,'yyyy') = '2019'
AND semester = 2
ORDER BY
s.studid;
/*7.List the student full name, unit code for those students who have no mark in any unit in
semester 1 of 2020. Sort the list by student full name.*/
SELECT
s.studid,
studfname,
studlname,
TO_CHAR(ofyear,'yyyy') AS "YEAR OF ENROLMENT",
semester,
e.unitcode
FROM
uni.student s
JOIN uni.enrolment e ON s.studid = e.studid
WHERE
mark IS NULL
AND TO_CHAR(ofyear,'yyyy') = '2020'
AND semester = 1; | true |
4e21c624f8e36986f8069c8b97c9627504ecc123 | SQL | juanOspina13/plsql-files | /Estandares/Estandares/OSS/Plantillas/Product/Nombre_Modulo/server/sql/02tbls/nombreTabla/04fkey/crFK_NombreCortoTablaOrigen_NombreCortoTablaDestinoNN.sql | ISO-8859-3 | 933 | 3.015625 | 3 | [] | no_license | --
-- Propiedad intelectual de OPEN International Systems Ltda
--
-- Archivo : crFK_<TablaOrigen>_<TablaDestino><NN>.sql
-- Autor : <Nombre Apellido del Autor> ( Autor inicial del archivo )
-- Fecha : <DD-MM-YYYY HH24:MI:SS> ( Fecha creacin )
--
-- Descripcion : Creacion de llave foranea tabla <TablaOrigen>
-- Observaciones :
--
-- Historia de Modificaciones
-- Fecha IDEntrega
--
-- DD-MM-YYYY <Autor>SAONNNNN
-- Modificacion
--
PROMPT - Script : crFK_<NombreCortoTablaOrigen>_<NombreCortoTablaDestino><NN>.sql
PROMPT - Author : <Nombre Apellido del Autor>
PROMPT
PROMPT - Adding foreing key FK_<NombreCortoTablaOrigen>_<NombreCortoTablaDestino><NN> to table <TablaOrigen>
ALTER TABLE <TablaOrigen> ADD
(
CONSTRAINT FK_<NombreCortoTablaOrigen>_<NombreCortoTablaDestino><NN>
FOREIGN KEY ( campo1, campoN )
REFERENCES <TablaDestino> ( campo1, campoN )
)
/
| true |
323fc6f51923ccaf94697229c5cd01bdcb36572e | SQL | lucyclevelromeeler/ezmodeler-svn-to-git | /branch/webapp/src/app/installation.sql | UTF-8 | 18,767 | 3.484375 | 3 | [] | no_license | SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL';
CREATE SCHEMA IF NOT EXISTS `mydb` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci ;
USE `mydb`;
-- -----------------------------------------------------
-- Table `mydb`.`fieldvalues`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`fieldvalues` ;
CREATE TABLE IF NOT EXISTS `mydb`.`fieldvalues` (
`fieldvalues_id` BIGINT NOT NULL ,
`name` VARCHAR(255) NULL DEFAULT NULL ,
`starttime` DATETIME NULL DEFAULT NULL ,
`updatetime` DATETIME NULL DEFAULT NULL ,
`deleted` VARCHAR(255) NULL DEFAULT NULL ,
PRIMARY KEY (`fieldvalues_id`) )
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`error_type`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`error_type` ;
CREATE TABLE IF NOT EXISTS `mydb`.`error_type` (
`errortype_id` BIGINT NOT NULL ,
`starttime` DATETIME NULL DEFAULT NULL ,
`updatetime` DATETIME NULL DEFAULT NULL ,
`deleted` VARCHAR(255) NULL DEFAULT NULL ,
`fieldvalues_id` BIGINT NULL DEFAULT NULL ,
PRIMARY KEY (`errortype_id`) ,
INDEX FK62B08B7176B7F57 (`fieldvalues_id` ASC) ,
CONSTRAINT `FK62B08B7176B7F57`
FOREIGN KEY (`fieldvalues_id` )
REFERENCES `mydb`.`fieldvalues` (`fieldvalues_id` ))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`error_values`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`error_values` ;
CREATE TABLE IF NOT EXISTS `mydb`.`error_values` (
`errorvalues_id` BIGINT NOT NULL ,
`starttime` DATETIME NULL DEFAULT NULL ,
`updatetime` DATETIME NULL DEFAULT NULL ,
`deleted` VARCHAR(255) NULL DEFAULT NULL ,
`fieldvalues_id` BIGINT NULL DEFAULT NULL ,
`errortype_id` BIGINT NULL DEFAULT NULL ,
PRIMARY KEY (`errorvalues_id`) ,
INDEX FKF576C92A76B7F57 (`fieldvalues_id` ASC) ,
INDEX FKF576C92A7942E9DD (`errortype_id` ASC) ,
CONSTRAINT `FKF576C92A76B7F57`
FOREIGN KEY (`fieldvalues_id` )
REFERENCES `mydb`.`fieldvalues` (`fieldvalues_id` ),
CONSTRAINT `FKF576C92A7942E9DD`
FOREIGN KEY (`errortype_id` )
REFERENCES `mydb`.`error_type` (`errortype_id` ))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`field_language`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`field_language` ;
CREATE TABLE IF NOT EXISTS `mydb`.`field_language` (
`language_id` BIGINT NOT NULL ,
`name` VARCHAR(255) NULL DEFAULT NULL ,
`starttime` DATETIME NULL DEFAULT NULL ,
`updatetime` DATETIME NULL DEFAULT NULL ,
`deleted` VARCHAR(255) NULL DEFAULT NULL ,
PRIMARY KEY (`language_id`) )
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`objecttype`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`objecttype` ;
CREATE TABLE IF NOT EXISTS `mydb`.`objecttype` (
`objecttype_id` INT NOT NULL ,
`name` VARCHAR(255) NULL ,
`description` TEXT NULL ,
`updatedby` INT NULL ,
`insertedby` INT NULL ,
`updated` DATETIME NULL ,
`inserted` DATETIME NULL ,
PRIMARY KEY (`objecttype_id`) )
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_bin;
-- -----------------------------------------------------
-- Table `mydb`.`baseobject`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`baseobject` ;
CREATE TABLE IF NOT EXISTS `mydb`.`baseobject` (
`baseobject_id` INT NOT NULL ,
`name` VARCHAR(255) NULL ,
`comment` TEXT NULL ,
`objecttype_id` INT NULL ,
`inserted` INT NULL ,
`updated` INT NULL ,
`insertedby` DATETIME NULL ,
`updatedby` DATETIME NULL ,
`deleted` VARCHAR(45) NULL ,
PRIMARY KEY (`baseobject_id`) ,
INDEX fk_objecttype_id (`objecttype_id` ASC) ,
CONSTRAINT `fk_objecttype_id`
FOREIGN KEY (`objecttype_id` )
REFERENCES `mydb`.`objecttype` (`objecttype_id` )
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_bin
COMMENT = 'These are the Base-Objects';
-- -----------------------------------------------------
-- Table `mydb`.`category`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`category` ;
CREATE TABLE IF NOT EXISTS `mydb`.`category` (
`category_id` INT NOT NULL ,
`name` VARCHAR(255) NULL ,
`insertedby` INT NULL ,
`updatedby` INT NULL ,
`inserted` DATETIME NULL ,
`updated` DATETIME NULL ,
`description` TEXT NULL ,
INDEX category_id () ,
PRIMARY KEY (`category_id`) )
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_bin;
-- -----------------------------------------------------
-- Table `mydb`.`object`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`object` ;
CREATE TABLE IF NOT EXISTS `mydb`.`object` (
`object_id` INT NOT NULL ,
`name` VARCHAR(255) NULL ,
`baseobject_id` INT NULL ,
`deleted` VARCHAR(45) NULL ,
`updatedBy` INT NULL ,
`insertedby` INT NULL ,
`updated` DATETIME NULL ,
`inserted` DATETIME NULL ,
`category_id` INT NULL ,
PRIMARY KEY (`object_id`) ,
INDEX fk_baseobject_id (`baseobject_id` ASC) ,
INDEX fk_category_id (`category_id` ASC) ,
CONSTRAINT `fk_baseobject_id`
FOREIGN KEY (`baseobject_id` )
REFERENCES `mydb`.`baseobject` (`baseobject_id` )
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_category_id`
FOREIGN KEY (`category_id` )
REFERENCES `mydb`.`category` (`category_id` )
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_bin;
-- -----------------------------------------------------
-- Table `mydb`.`diagramrevision`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`diagramrevision` ;
CREATE TABLE IF NOT EXISTS `mydb`.`diagramrevision` (
`diagramrevision_id` INT NOT NULL ,
`insertedby` INT NULL ,
`inserted` DATETIME NULL ,
`comment` VARCHAR(255) NULL ,
`updatedby` INT NULL ,
`updated` DATETIME NULL ,
`deleted` VARCHAR(45) NULL ,
PRIMARY KEY (`diagramrevision_id`) )
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_bin;
-- -----------------------------------------------------
-- Table `mydb`.`diagram`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`diagram` ;
CREATE TABLE IF NOT EXISTS `mydb`.`diagram` (
`diagram_id` INT NOT NULL ,
`name` VARCHAR(255) NULL ,
`description` TEXT NULL ,
`updatedby` INT NULL ,
`insertedby` INT NULL ,
`updated` DATETIME NULL ,
`inserted` DATETIME NULL ,
`revision_number` INT NULL ,
`diagramrevision_id` INT NULL ,
`deleted` VARCHAR(45) NULL ,
`parent_diagram_id` INT NULL ,
PRIMARY KEY (`diagram_id`) ,
INDEX fk_diagramrevision_id (`diagramrevision_id` ASC) ,
CONSTRAINT `fk_diagramrevision_id`
FOREIGN KEY (`diagramrevision_id` )
REFERENCES `mydb`.`diagramrevision` (`diagramrevision_id` )
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_bin;
-- -----------------------------------------------------
-- Table `mydb`.`markercategory`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`markercategory` ;
CREATE TABLE IF NOT EXISTS `mydb`.`markercategory` (
`markercategory_id` INT NOT NULL ,
`name` VARCHAR(255) NULL ,
`comment` TEXT NULL ,
`insertedby` INT NULL ,
`updatedby` INT NULL ,
`inserted` DATETIME NULL ,
`updated` DATETIME NULL ,
`deleted` VARCHAR(45) NULL ,
PRIMARY KEY (`markercategory_id`) )
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_bin;
-- -----------------------------------------------------
-- Table `mydb`.`objectmarker`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`objectmarker` ;
CREATE TABLE IF NOT EXISTS `mydb`.`objectmarker` (
`objectmarker_id` INT NOT NULL ,
`name` VARCHAR(255) NULL ,
`comment` TEXT NULL ,
`priority` INT NULL ,
`markercategory_id` INT NULL ,
`insertedby` INT NULL ,
`updatedby` INT NULL ,
`inserted` DATETIME NULL ,
`updated` DATETIME NULL ,
`deleted` VARCHAR(45) NULL ,
PRIMARY KEY (`objectmarker_id`) ,
INDEX fk_markercategory_id (`markercategory_id` ASC) ,
CONSTRAINT `fk_markercategory_id`
FOREIGN KEY (`markercategory_id` )
REFERENCES `mydb`.`markercategory` (`markercategory_id` )
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_bin
COMMENT = 'Marker-Object';
-- -----------------------------------------------------
-- Table `mydb`.`diagram_object`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`diagram_object` ;
CREATE TABLE IF NOT EXISTS `mydb`.`diagram_object` (
`diagram_object_id` INT NOT NULL ,
`diagram_id` INT NULL ,
`object_id` INT NULL ,
`marker_id` INT NULL ,
`deleted` VARCHAR(45) NULL ,
`objectmarker_id` INT NULL ,
`inserted` DATETIME NULL ,
`insertedby` INT NULL ,
PRIMARY KEY (`diagram_object_id`) ,
INDEX fk_diagram_id (`diagram_id` ASC) ,
INDEX fk_object_id (`object_id` ASC) ,
INDEX fk_objectmarker_id (`objectmarker_id` ASC) ,
CONSTRAINT `fk_diagram_id`
FOREIGN KEY (`diagram_id` )
REFERENCES `mydb`.`diagram` (`diagram_id` )
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_object_id`
FOREIGN KEY (`object_id` )
REFERENCES `mydb`.`object` (`object_id` )
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_objectmarker_id`
FOREIGN KEY (`objectmarker_id` )
REFERENCES `mydb`.`objectmarker` (`objectmarker_id` )
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_bin;
-- -----------------------------------------------------
-- Table `mydb`.`emails`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`emails` ;
CREATE TABLE IF NOT EXISTS `mydb`.`emails` (
`mail_id` BIGINT NOT NULL ,
`comment` VARCHAR(255) NULL DEFAULT NULL ,
`email` VARCHAR(255) NULL DEFAULT NULL ,
`startdate` DATETIME NULL DEFAULT NULL ,
`updatedate` DATETIME NULL DEFAULT NULL ,
`deleted` VARCHAR(255) NULL DEFAULT NULL ,
PRIMARY KEY (`mail_id`) )
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`adresses`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`adresses` ;
CREATE TABLE IF NOT EXISTS `mydb`.`adresses` (
`adresses_id` NULL );
-- -----------------------------------------------------
-- Table `mydb`.`adresses_emails`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`adresses_emails` ;
CREATE TABLE IF NOT EXISTS `mydb`.`adresses_emails` (
`adresses_emails_id` BIGINT NOT NULL ,
`adresses_id` BIGINT NULL DEFAULT NULL ,
`mail_id` BIGINT NULL DEFAULT NULL ,
`starttime` DATETIME NULL DEFAULT NULL ,
`updatetime` DATETIME NULL DEFAULT NULL ,
`deleted` VARCHAR(255) NULL DEFAULT NULL ,
PRIMARY KEY (`adresses_emails_id`) ,
INDEX FKA30D5F5231F52DC7 (`mail_id` ASC) ,
INDEX FKA30D5F52A40D68C7 (`adresses_id` ASC) ,
CONSTRAINT `FKA30D5F5231F52DC7`
FOREIGN KEY (`mail_id` )
REFERENCES `mydb`.`emails` (`mail_id` ),
CONSTRAINT `FKA30D5F52A40D68C7`
FOREIGN KEY (`adresses_id` )
REFERENCES `mydb`.`adresses` ())
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`adresses_phones`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`adresses_phones` ;
CREATE TABLE IF NOT EXISTS `mydb`.`adresses_phones` (
`adresses_phone_id` BIGINT NOT NULL ,
`adresses_id` BIGINT NULL DEFAULT NULL ,
`phone_id` BIGINT NULL DEFAULT NULL ,
`starttime` DATETIME NULL DEFAULT NULL ,
`updatetime` DATETIME NULL DEFAULT NULL ,
`deleted` VARCHAR(255) NULL DEFAULT NULL ,
PRIMARY KEY (`adresses_phone_id`) )
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`configuration`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`configuration` ;
CREATE TABLE IF NOT EXISTS `mydb`.`configuration` (
`configuration_id` BIGINT NOT NULL ,
`comment` VARCHAR(255) NULL DEFAULT NULL ,
`conf_key` VARCHAR(255) NULL DEFAULT NULL ,
`conf_value` VARCHAR(255) NULL DEFAULT NULL ,
`starttime` DATETIME NULL DEFAULT NULL ,
`updatetime` DATETIME NULL DEFAULT NULL ,
`deleted` VARCHAR(255) NULL DEFAULT NULL ,
`user_id` BIGINT NULL DEFAULT NULL ,
PRIMARY KEY (`configuration_id`) )
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`fieldvalues`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`fieldvalues` ;
CREATE TABLE IF NOT EXISTS `mydb`.`fieldvalues` (
`fieldvalues_id` BIGINT NOT NULL ,
`name` VARCHAR(255) NULL DEFAULT NULL ,
`starttime` DATETIME NULL DEFAULT NULL ,
`updatetime` DATETIME NULL DEFAULT NULL ,
`deleted` VARCHAR(255) NULL DEFAULT NULL ,
PRIMARY KEY (`fieldvalues_id`) )
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`organisation`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`organisation` ;
CREATE TABLE IF NOT EXISTS `mydb`.`organisation` (
`organisation_id` BIGINT NOT NULL ,
`insertedby` BIGINT NULL DEFAULT NULL ,
`name` VARCHAR(255) NULL DEFAULT NULL ,
`updatedby` BIGINT NULL DEFAULT NULL ,
`starttime` DATETIME NULL DEFAULT NULL ,
`updatetime` DATETIME NULL DEFAULT NULL ,
`deleted` VARCHAR(255) NULL DEFAULT NULL ,
PRIMARY KEY (`organisation_id`) )
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`naviglobal`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`naviglobal` ;
CREATE TABLE IF NOT EXISTS `mydb`.`naviglobal` (
`global_id` BIGINT NOT NULL ,
`action` VARCHAR(255) NULL DEFAULT NULL ,
`comment` VARCHAR(255) NULL DEFAULT NULL ,
`icon` VARCHAR(255) NULL DEFAULT NULL ,
`isleaf` BIT NULL DEFAULT NULL ,
`isopen` BIT NULL DEFAULT NULL ,
`starttime` DATETIME NULL DEFAULT NULL ,
`updatetime` DATETIME NULL DEFAULT NULL ,
`deleted` VARCHAR(255) NULL DEFAULT NULL ,
`name` VARCHAR(255) NULL DEFAULT NULL ,
`naviorder` INT NULL DEFAULT NULL ,
`level_id` BIGINT NULL DEFAULT NULL ,
`label_number` BIGINT NULL DEFAULT NULL ,
PRIMARY KEY (`global_id`) )
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`navimain`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`navimain` ;
CREATE TABLE IF NOT EXISTS `mydb`.`navimain` (
`main_id` BIGINT NOT NULL ,
`action` VARCHAR(255) NULL DEFAULT NULL ,
`level_id` BIGINT NULL DEFAULT NULL ,
`global_id` BIGINT NULL DEFAULT NULL ,
`comment` VARCHAR(255) NULL DEFAULT NULL ,
`icon` VARCHAR(255) NULL DEFAULT NULL ,
`isleaf` BIT NULL DEFAULT NULL ,
`isopen` BIT NULL DEFAULT NULL ,
`starttime` DATETIME NULL DEFAULT NULL ,
`updatetime` DATETIME NULL DEFAULT NULL ,
`deleted` VARCHAR(255) NULL DEFAULT NULL ,
`name` VARCHAR(255) NULL DEFAULT NULL ,
`naviorder` INT NULL DEFAULT NULL ,
`label_number` BIGINT NULL DEFAULT NULL ,
PRIMARY KEY (`main_id`) ,
INDEX FK7D543E5F363F971D (`global_id` ASC) ,
CONSTRAINT `FK7D543E5F363F971D`
FOREIGN KEY (`global_id` )
REFERENCES `mydb`.`naviglobal` (`global_id` ))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`navisub`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`navisub` ;
CREATE TABLE IF NOT EXISTS `mydb`.`navisub` (
`sub_id` BIGINT NOT NULL ,
`main_id` BIGINT NULL DEFAULT NULL ,
`level_id` BIGINT NULL DEFAULT NULL ,
`action` VARCHAR(255) NULL DEFAULT NULL ,
`comment` VARCHAR(255) NULL DEFAULT NULL ,
`icon` VARCHAR(255) NULL DEFAULT NULL ,
`isleaf` BIT NULL DEFAULT NULL ,
`isopen` BIT NULL DEFAULT NULL ,
`name` VARCHAR(255) NULL DEFAULT NULL ,
`naviorder` INT NULL DEFAULT NULL ,
`starttime` DATETIME NULL DEFAULT NULL ,
`updatetime` DATETIME NULL DEFAULT NULL ,
`deleted` VARCHAR(255) NULL DEFAULT NULL ,
`label_number` BIGINT NULL DEFAULT NULL ,
PRIMARY KEY (`sub_id`) ,
INDEX FK6723D8DA8D368C1D (`main_id` ASC) ,
CONSTRAINT `FK6723D8DA8D368C1D`
FOREIGN KEY (`main_id` )
REFERENCES `mydb`.`navimain` (`main_id` ))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`users`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`users` ;
CREATE TABLE IF NOT EXISTS `mydb`.`users` (
`user_id` BIGINT NOT NULL ,
`adresses_id` BIGINT NULL DEFAULT NULL ,
`age` DATETIME NULL DEFAULT NULL ,
`availible` INT NULL DEFAULT NULL ,
`firstname` VARCHAR(255) NULL DEFAULT NULL ,
`lastlogin` DATETIME NULL DEFAULT NULL ,
`lastname` VARCHAR(255) NULL DEFAULT NULL ,
`lasttrans` BIGINT NULL DEFAULT NULL ,
`level_id` BIGINT NULL DEFAULT NULL ,
`login` VARCHAR(255) NULL DEFAULT NULL ,
`password` VARCHAR(255) NULL DEFAULT NULL ,
`regdate` DATETIME NULL DEFAULT NULL ,
`status` INT NULL DEFAULT NULL ,
`title_id` INT NULL DEFAULT NULL ,
`starttime` DATETIME NULL DEFAULT NULL ,
`updatetime` DATETIME NULL DEFAULT NULL ,
`deleted` VARCHAR(255) NULL DEFAULT NULL ,
`pictureuri` VARCHAR(255) NULL DEFAULT NULL ,
`language_id` BIGINT NULL DEFAULT NULL ,
`resethash` VARCHAR(255) NULL DEFAULT NULL ,
PRIMARY KEY (`user_id`) ,
INDEX FK6A68E08A40D68C7 (`adresses_id` ASC) ,
CONSTRAINT `FK6A68E08A40D68C7`
FOREIGN KEY (`adresses_id` )
REFERENCES `mydb`.`adresses` (`adresses_id` ))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`users_usergroups`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`users_usergroups` ;
CREATE TABLE IF NOT EXISTS `mydb`.`users_usergroups` (
`users_usergroups_id` BIGINT NOT NULL ,
`comment` VARCHAR(255) NULL DEFAULT NULL ,
`starttime` DATETIME NULL DEFAULT NULL ,
`updatetime` DATETIME NULL DEFAULT NULL ,
`deleted` VARCHAR(255) NULL DEFAULT NULL ,
`user_id` BIGINT NULL DEFAULT NULL ,
`usergroup_id` BIGINT NULL DEFAULT NULL ,
PRIMARY KEY (`users_usergroups_id`) )
ENGINE = InnoDB;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
| true |
2e8052e7bc633ebc4205bc07653d371090774a00 | SQL | shaque21/studentManagementSystem.github.io | /database/student_management.sql | UTF-8 | 3,025 | 3.3125 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 5.0.2
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Dec 01, 2020 at 07:40 PM
-- Server version: 10.4.14-MariaDB
-- PHP Version: 7.3.22
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `student_management_system`
--
-- --------------------------------------------------------
--
-- Table structure for table `student_info`
--
CREATE TABLE `student_info` (
`id` int(11) NOT NULL,
`name` varchar(255) NOT NULL,
`roll` int(7) NOT NULL,
`semester` varchar(30) NOT NULL,
`city` varchar(255) NOT NULL,
`mobile` varchar(15) NOT NULL,
`photo` varchar(255) NOT NULL,
`date` datetime NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `student_info`
--
INSERT INTO `student_info` (`id`, `name`, `roll`, `semester`, `city`, `mobile`, `photo`, `date`) VALUES
(6, 'Hanin Tahsin', 7161015, '8th', 'Khilgaon', '01677102422', 'Hanin Tahsin.13668975_271708919864016_6674875747466576750_n.jpg', '2020-12-01 23:22:58'),
(8, 'Md Ikbal', 8161008, '7th', 'Khilkhet', '01687546952', 'Md Ikbal.download.jpg', '2020-12-02 00:23:54'),
(9, 'Md Osama Sharif', 7161035, '8th', 'Old Town', '01622102422', 'Md Osama Sharif.download.png', '2020-12-02 00:25:22');
-- --------------------------------------------------------
--
-- Table structure for table `user`
--
CREATE TABLE `user` (
`id` int(11) NOT NULL,
`name` varchar(50) NOT NULL,
`username` varchar(50) NOT NULL,
`email` varchar(255) NOT NULL,
`password` varchar(255) NOT NULL,
`photo` varchar(255) NOT NULL,
`date` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `user`
--
INSERT INTO `user` (`id`, `name`, `username`, `email`, `password`, `photo`, `date`) VALUES
(20, 'Samsul Haque', 'admin', 'admin@gmail.com', 'admin', 'admin.jpg', '2020-12-01 16:51:05'),
(21, 'Kabel Uddin', 'kabelcse', 'kabelcse@gmail.com', 'kabel', 'kabelcse.jpg', '2020-12-01 18:33:13');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `student_info`
--
ALTER TABLE `student_info`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `user`
--
ALTER TABLE `user`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `username` (`username`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `student_info`
--
ALTER TABLE `student_info`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=10;
--
-- AUTO_INCREMENT for table `user`
--
ALTER TABLE `user`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=22;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
| true |
d759bf9b67801e2ad6b745d4ae7f65534eea9df7 | SQL | yanoandri/SalesOrder-Pro | /PFSHelper.DataAccessLayer/dbFrameworkPFS/dbFrameworkPFS/dbo/Stored Procedures/uspPSC_ExceptionFormList.sql | UTF-8 | 4,063 | 3.390625 | 3 | [] | no_license |
/***********************************************************************************************************************
Copyright (c) 2015 PT Profescipta Wahanatehnik. All Rights Reserved.
This software, all associated documentation, and all copies
DESCRIPTION
Name : uspPSC_ExceptionFormList
Desc : This store procedure is use to get list of PSC_EXCEPTION_FORM
Create Date : 21 Jan 2015 - Created By : PFS Generator v5.1
Modified Date : - Modified By :
Comments :
Sample Data :
***********************************************************************************************************************/
CREATE PROCEDURE dbo.uspPSC_ExceptionFormList
(
@sKeyWords VARCHAR(1280) = NULL,
@iBranchID INT = NULL,
@iAssetClassID INT = NULL,
@iProductRatingID INT = NULL,
@dtExceptionDateFrom DATETIME = NULL,
@dtExceptionDateTo DATETIME = NULL,
@dtApprovedDateFrom DATETIME = NULL,
@dtApprovedDateTo DATETIME = NULL,
@dtExpiryDateFrom DATETIME = NULL,
@dtExpiryDateTo DATETIME = NULL,
@bIsActive BIT = NULL,
@bIsDeleted BIT = NULL,
@dtCreateDateFrom DATETIME = NULL,
@dtCreateDateTo DATETIME = NULL,
@iCreateByUserID INT = NULL,
@dtUpdateDateFrom DATETIME = NULL,
@dtUpdateDateTo DATETIME = NULL,
@iUpdateByUserID INT = NULL,
@bIsNeedApproval BIT = NULL
)
AS
BEGIN
SELECT
pef0.psc_exception_form_id,
pef0.com_branch_id,
pef0.branch_name,
pef0.cif,
pef0.customer_full_name,
pef0.com_asset_class_id,
pef0.com_product_rating_id,
pef0.exception_date,
pef0.approved_date,
pef0.expiry_date,
pef0.is_active,
pef0.is_deleted,
pef0.create_date,
pef0.create_by_user_id,
pef0.update_date,
pef0.update_by_user_id,
pef0.is_need_approval,
cb1.branch_code,
cb1.branch_name,
cac2.asset_class_code,
cac2.asset_class_name
FROM
psc_exception_form pef0 WITH (NOLOCK),
com_branch cb1 WITH (NOLOCK),
com_asset_class cac2 WITH (NOLOCK),
com_product_rating cpr3 WITH (NOLOCK)
WHERE
pef0.com_branch_id = cb1.com_branch_id AND
pef0.com_asset_class_id = cac2.com_asset_class_id AND
pef0.com_product_rating_id = cpr3.com_product_rating_id AND
(@iBranchID IS NULL OR pef0.com_branch_id = @iBranchID) AND
(@iAssetClassID IS NULL OR pef0.com_asset_class_id = @iAssetClassID) AND
(@iProductRatingID IS NULL OR pef0.com_product_rating_id = @iProductRatingID) AND
(@dtExceptionDateFrom IS NULL OR CONVERT(VARCHAR, pef0.exception_date, 12) >= CONVERT(VARCHAR, @dtExceptionDateFrom, 12)) AND
(@dtExceptionDateTo IS NULL OR CONVERT(VARCHAR, pef0.exception_date, 12) <= CONVERT(VARCHAR, @dtExceptionDateTo, 12)) AND
(@dtApprovedDateFrom IS NULL OR CONVERT(VARCHAR, pef0.approved_date, 12) >= CONVERT(VARCHAR, @dtApprovedDateFrom, 12)) AND
(@dtApprovedDateTo IS NULL OR CONVERT(VARCHAR, pef0.approved_date, 12) <= CONVERT(VARCHAR, @dtApprovedDateTo, 12)) AND
(@dtExpiryDateFrom IS NULL OR CONVERT(VARCHAR, pef0.expiry_date, 12) >= CONVERT(VARCHAR, @dtExpiryDateFrom, 12)) AND
(@dtExpiryDateTo IS NULL OR CONVERT(VARCHAR, pef0.expiry_date, 12) <= CONVERT(VARCHAR, @dtExpiryDateTo, 12)) AND
(@bIsActive IS NULL OR pef0.is_active = @bIsActive) AND
(@bIsDeleted IS NULL OR pef0.is_deleted = @bIsDeleted) AND
(@dtCreateDateFrom IS NULL OR CONVERT(VARCHAR, pef0.create_date, 12) >= CONVERT(VARCHAR, @dtCreateDateFrom, 12)) AND
(@dtCreateDateTo IS NULL OR CONVERT(VARCHAR, pef0.create_date, 12) <= CONVERT(VARCHAR, @dtCreateDateTo, 12)) AND
(@iCreateByUserID IS NULL OR pef0.create_by_user_id = @iCreateByUserID) AND
(@dtUpdateDateFrom IS NULL OR CONVERT(VARCHAR, pef0.update_date, 12) >= CONVERT(VARCHAR, @dtUpdateDateFrom, 12)) AND
(@dtUpdateDateTo IS NULL OR CONVERT(VARCHAR, pef0.update_date, 12) <= CONVERT(VARCHAR, @dtUpdateDateTo, 12)) AND
(@iUpdateByUserID IS NULL OR pef0.update_by_user_id = @iUpdateByUserID) AND
(@bIsNeedApproval IS NULL OR pef0.is_need_approval = @bIsNeedApproval) AND
(@sKeyWords IS NULL OR
pef0.branch_name LIKE '%' + @sKeyWords + '%' OR
pef0.cif LIKE '%' + @sKeyWords + '%' OR
pef0.customer_full_name LIKE '%' + @sKeyWords + '%')
END
| true |
6f6d645666ef02693d28d4161b19ee807ee30ed0 | SQL | beaulirl/photoalbum | /photoalbum.sql | UTF-8 | 2,733 | 3.28125 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 4.3.11
-- http://www.phpmyadmin.net
--
-- Хост: 127.0.0.1
-- Время создания: Мар 20 2016 г., 18:57
-- Версия сервера: 5.6.24
-- Версия PHP: 5.6.8
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
--
-- База данных: `zf2tutorial`
--
-- --------------------------------------------------------
--
-- Структура таблицы `photoalbum`
--
CREATE TABLE IF NOT EXISTS `photoalbum` (
`id` int(11) NOT NULL,
`name` varchar(50) NOT NULL,
`describes` varchar(200) NOT NULL,
`ph_name` varchar(50) NOT NULL,
`email` varchar(20) NOT NULL,
`phone` varchar(20) NOT NULL,
`data_download` date NOT NULL,
`data_change` datetime NOT NULL,
`count` int(50) NOT NULL,
`cover` varchar(200) NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;
--
-- Дамп данных таблицы `photoalbum`
--
INSERT INTO `photoalbum` (`id`, `name`, `describes`, `ph_name`, `email`, `phone`, `data_download`, `data_change`, `count`, `cover`) VALUES
(1, 'Пейзажи', 'очень красивые фото', 'Anna', 'adf@ka.ru', '+7(940)456-45-45', '0000-00-00', '2016-03-15 14:00:12', 3, 'tn_-1600×1200.jpg'),
(2, 'Портреты', 'красивые портреты', 'Jon', 'jin@ff.ru', '+7(943)234-34-56', '0000-00-00', '2016-03-15 13:59:46', 9, 'tn_12_6845_oboi_prekrasnyj_den_1024x768.jpg'),
(3, 'Натюрморты', 'красивые натюрморты', 'Ivan', 'ivan@gaol.con', '+7(984)456-55-76', '2016-03-03', '2016-03-15 13:59:27', 5, 'tn_13_4225.jpg'),
(4, 'Улицы', 'пейзажи нижегородских улиц', 'Arina', 'ar@ha.com', '+7(965)567-76-33', '2016-03-03', '2016-03-15 13:59:03', 8, 'tn_13_4213.jpg'),
(5, 'Парки', 'парки города', 'Thom', 'tom@fad.com', '+7(965)567-79-33', '2016-03-09', '2016-03-15 13:50:47', 3, 'tn_1.jpg');
--
-- Индексы сохранённых таблиц
--
--
-- Индексы таблицы `photoalbum`
--
ALTER TABLE `photoalbum`
ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `name` (`name`);
--
-- AUTO_INCREMENT для сохранённых таблиц
--
--
-- AUTO_INCREMENT для таблицы `photoalbum`
--
ALTER TABLE `photoalbum`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=6;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
| true |
08568708d213a6129628703d774018e571974790 | SQL | tomseng/Mission1-Registre-de-WebService | /BDD/mission1bdd.sql | UTF-8 | 1,192 | 2.84375 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 4.5.1
-- http://www.phpmyadmin.net
--
-- Client : 127.0.0.1
-- Généré le : Ven 20 Mai 2016 à 15:31
-- Version du serveur : 10.1.10-MariaDB
-- Version de PHP : 7.0.4
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Base de données : `mission1bdd`
--
-- --------------------------------------------------------
--
-- Structure de la table `webservice`
--
CREATE TABLE `webservice` (
`IDWS` int(11) NOT NULL,
`TYPEWS` varchar(25) NOT NULL,
`COMMENTAIREWS` varchar(200) NOT NULL,
`NOMWS` varchar(25) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Index pour les tables exportées
--
--
-- Index pour la table `webservice`
--
ALTER TABLE `webservice`
ADD PRIMARY KEY (`IDWS`);
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
| true |
8991205f2dc5853d380c23c10bc84c81e49f7599 | SQL | HyunupKang/StudySQLServer | /210518/Test3.sql | UHC | 282 | 3.109375 | 3 | [] | no_license | SELECT b.Idx
, CONCAT(' : ', b.Names) AS Names
, CONCAT(' > ', b.Author) AS Author
, FORMAT(b.ReleaseDate,'yyyy MM dd') AS ''
, b.ISBN
, CONCAT(FORMAT( b.Price, 'N0', 'en-us'), '') AS ''
FROM bookstbl AS b
ORDER BY b.Idx DESC
| true |
a54c41ab22a2e7684703ee2791e6059ed07b3e63 | SQL | ManuelPrandini/SanitarySystemProject | /DBScripts/HospitalDB_190619_113002.sql | UTF-8 | 5,586 | 3.3125 | 3 | [] | no_license | -- Group [Group]
create table `group` (
`oid` integer not null,
`groupname` varchar(255),
primary key (`oid`)
);
-- Module [Module]
create table `module` (
`oid` integer not null,
`moduleid` varchar(255),
`modulename` varchar(255),
primary key (`oid`)
);
-- User [User]
create table `user` (
`cf` integer not null,
`username` varchar(255),
`password` varchar(255),
`email` varchar(255),
`name` varchar(255),
`surname` varchar(255),
`birthday` date,
primary key (`cf`)
);
-- Pharmacist [ent1]
create table `pharmacist` (
`pharmacist_code` varchar(255)
);
-- Drug [ent2]
create table `drug` (
`id` integer not null,
`isstandard` bit,
`name` varchar(255),
primary key (`id`)
);
-- Visit [ent3]
create table `visit` (
`idvisita` integer not null,
`date` datetime,
primary key (`idvisita`)
);
-- treatment [ent5]
create table `treatment` (
`idtreatment` integer not null,
`enddate` date,
`startdate` date,
primary key (`idtreatment`)
);
-- Patient [ent6]
create table `patient` (
`weight` integer,
`height` integer
);
-- ClinicalOperation [ent7]
create table `clinicaloperation` (
`idclinicaloperation` integer not null,
`date` datetime,
primary key (`idclinicaloperation`)
);
-- Medical_specialization [ent8]
create table `medical_specialization` (
`namespecialization` varchar(255) not null,
primary key (`namespecialization`)
);
-- Doctor [ent9]
create table `doctor` (
`doctor_code` varchar(255)
);
-- Group_DefaultModule [Group2DefaultModule_DefaultModule2Group]
alter table `group` add column `module_oid` integer;
alter table `group` add index fk_group_module (`module_oid`), add constraint fk_group_module foreign key (`module_oid`) references `module` (`oid`);
-- Group_Module [Group2Module_Module2Group]
create table `group_module` (
`group_oid` integer not null,
`module_oid` integer not null,
primary key (`group_oid`, `module_oid`)
);
alter table `group_module` add index fk_group_module_group (`group_oid`), add constraint fk_group_module_group foreign key (`group_oid`) references `group` (`oid`);
alter table `group_module` add index fk_group_module_module (`module_oid`), add constraint fk_group_module_module foreign key (`module_oid`) references `module` (`oid`);
-- User_DefaultGroup [User2DefaultGroup_DefaultGroup2User]
alter table `user` add column `group_oid` integer;
alter table `user` add index fk_user_group (`group_oid`), add constraint fk_user_group foreign key (`group_oid`) references `group` (`oid`);
-- User_Group [User2Group_Group2User]
create table `user_group` (
`user_cf` integer not null,
`group_oid` integer not null,
primary key (`user_cf`, `group_oid`)
);
alter table `user_group` add index fk_user_group_user (`user_cf`), add constraint fk_user_group_user foreign key (`user_cf`) references `user` (`cf`);
alter table `user_group` add index fk_user_group_group (`group_oid`), add constraint fk_user_group_group foreign key (`group_oid`) references `group` (`oid`);
-- User_Pharmacist [rel12]
alter table `pharmacist` add column `user_cf` integer;
alter table `pharmacist` add index fk_pharmacist_user (`user_cf`), add constraint fk_pharmacist_user foreign key (`user_cf`) references `user` (`cf`);
-- User_Patient [rel13]
alter table `patient` add column `user_cf` integer;
alter table `patient` add index fk_patient_user (`user_cf`), add constraint fk_patient_user foreign key (`user_cf`) references `user` (`cf`);
-- User_Doctor [rel14]
alter table `doctor` add column `user_cf` integer;
alter table `doctor` add index fk_doctor_user (`user_cf`), add constraint fk_doctor_user foreign key (`user_cf`) references `user` (`cf`);
-- Pharmacist_Drug [rel2]
create table `pharmacist_drug` (
`drug_id` integer not null,
primary key (`drug_id`)
);
alter table `pharmacist_drug` add index fk_pharmacist_drug_pharmacist (), add constraint fk_pharmacist_drug_pharmacist foreign key () references `pharmacist` ();
alter table `pharmacist_drug` add index fk_pharmacist_drug_drug (`drug_id`), add constraint fk_pharmacist_drug_drug foreign key (`drug_id`) references `drug` (`id`);
-- Visit_Doctor [rel3]
alter table `visit` add index fk_visit_doctor (), add constraint fk_visit_doctor foreign key () references `doctor` ();
-- Doctor_Medical_specialization [rel4]
alter table `doctor` add column `name` varchar(255);
alter table `doctor` add index fk_doctor_medical_specializati (`name`), add constraint fk_doctor_medical_specializati foreign key (`name`) references `medical_specialization` (`namespecialization`);
-- Visit_treatment [rel6]
alter table `treatment` add column `id` integer;
alter table `treatment` add index fk_treatment_visit (`id`), add constraint fk_treatment_visit foreign key (`id`) references `visit` (`idvisita`);
-- Drug_Patient [rel7]
alter table `drug` add index fk_drug_patient (), add constraint fk_drug_patient foreign key () references `patient` ();
-- treatment_Drug [rel8]
alter table `drug` add column `treatment_id` integer;
alter table `drug` add index fk_drug_treatment (`treatment_id`), add constraint fk_drug_treatment foreign key (`treatment_id`) references `treatment` (`idtreatment`);
-- Visit_ClinicalOperation [rel9]
alter table `clinicaloperation` add column `id` integer;
alter table `clinicaloperation` add index fk_clinicaloperation_visit (`id`), add constraint fk_clinicaloperation_visit foreign key (`id`) references `visit` (`idvisita`);
| true |
bd99d998720f3c62b0a8b0ea56c7fc687135be20 | SQL | Bouyonteknolojik/kamizay | /000 DB/2018.03.11.dev.kamizay.sql | UTF-8 | 5,287 | 3.0625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | -- phpMyAdmin SQL Dump
-- version 4.7.4
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1:3306
-- Generation Time: Mar 11, 2018 at 07:14 AM
-- Server version: 5.7.19
-- PHP Version: 5.6.31
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `kamizay`
--
-- --------------------------------------------------------
--
-- Table structure for table `albums`
--
DROP TABLE IF EXISTS `albums`;
CREATE TABLE IF NOT EXISTS `albums` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(100) NOT NULL,
`year` int(11) DEFAULT NULL,
`id_lst_album_types` int(11) DEFAULT NULL,
`created` timestamp NOT NULL,
`modified` timestamp NOT NULL,
`status` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Table structure for table `biographies`
--
DROP TABLE IF EXISTS `biographies`;
CREATE TABLE IF NOT EXISTS `biographies` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`id_musicians` int(11) NOT NULL,
`notes` text NOT NULL,
`created` timestamp NOT NULL,
`updated` timestamp NOT NULL,
`status` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Table structure for table `discographies`
--
DROP TABLE IF EXISTS `discographies`;
CREATE TABLE IF NOT EXISTS `discographies` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`id_songs` int(11) DEFAULT NULL,
`id_musicians` int(11) NOT NULL,
`id_lst_musician_roles` int(11) NOT NULL,
`notes` text,
`created` timestamp NOT NULL,
`updated` timestamp NOT NULL,
`status` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Table structure for table `lst_album_type`
--
DROP TABLE IF EXISTS `lst_album_type`;
CREATE TABLE IF NOT EXISTS `lst_album_type` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL,
`notes` text,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Table structure for table `lst_musician_roles`
--
DROP TABLE IF EXISTS `lst_musician_roles`;
CREATE TABLE IF NOT EXISTS `lst_musician_roles` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL,
`notes` text,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Table structure for table `lst_music_types`
--
DROP TABLE IF EXISTS `lst_music_types`;
CREATE TABLE IF NOT EXISTS `lst_music_types` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) DEFAULT NULL,
`notes` text,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Table structure for table `lst_user_roles`
--
DROP TABLE IF EXISTS `lst_user_roles`;
CREATE TABLE IF NOT EXISTS `lst_user_roles` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL,
`notes` text,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Table structure for table `musicians`
--
DROP TABLE IF EXISTS `musicians`;
CREATE TABLE IF NOT EXISTS `musicians` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`firstname` varchar(250) NOT NULL,
`lastname` varchar(50) NOT NULL,
`stagename` varchar(50) DEFAULT NULL,
`dob` date DEFAULT NULL,
`dod` date DEFAULT NULL,
`created` timestamp NULL DEFAULT NULL,
`updated` timestamp NULL DEFAULT NULL,
`status` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Table structure for table `songs`
--
DROP TABLE IF EXISTS `songs`;
CREATE TABLE IF NOT EXISTS `songs` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`id_albums` int(11) DEFAULT NULL,
`id_lst_music_types` int(11) DEFAULT NULL,
`title` varchar(100) NOT NULL,
`year` int(11) DEFAULT NULL,
`notes` text,
`created` timestamp NOT NULL,
`updated` timestamp NOT NULL,
`status` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Table structure for table `users`
--
DROP TABLE IF EXISTS `users`;
CREATE TABLE IF NOT EXISTS `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(250) NOT NULL,
`password` varchar(25) NOT NULL,
`name` varchar(255) DEFAULT NULL,
`id_lst_user_roles` int(11) DEFAULT NULL,
`created` timestamp NULL DEFAULT NULL,
`updated` timestamp NULL DEFAULT NULL,
`status` int(11) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `users_username_uindex` (`username`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
| true |
f0b86636883ebb02bf4d6c278915c92464a0d84c | SQL | as12334/xy-creditbox | /tools/i8nSql/新增新语言站点前.sql | UTF-8 | 1,575 | 3.34375 | 3 | [] | no_license | /**
* 以下脚本均在gb-companies库, 请注意修改对应语言(语言代号,货币代号)
*/
-- 字典:支持货币
INSERT INTO sys_dict ("module", "dict_type", "dict_code", "order_num", "remark", "parent_code", "active")
SELECT 'common', 'currency', 'JPY', '4', '货币代码:JPY日元', NULL, TRUE WHERE NOT EXISTS (SELECT "id" FROM sys_dict WHERE dict_type = 'currency' AND dict_code = 'JPY');
-- 字典:语言类型
INSERT INTO sys_dict ("module", "dict_type", "dict_code", "order_num", "remark", "parent_code", "active")
SELECT 'common', 'language', 'ja_JP', '4', '语言类型:日语', NULL, TRUE WHERE NOT EXISTS (SELECT "id" FROM sys_dict WHERE dict_type = 'language' AND dict_code = 'ja_JP');
-- 站点经营地区
INSERT INTO site_operate_area ("site_id", "code", "status", "area_ip", "open_time")
SELECT -1, 'JP', '1', '', now() WHERE NOT EXISTS (SELECT "id" FROM site_operate_area WHERE site_id = -1 AND code = 'JP');
-- 站点语言
INSERT INTO site_language ("site_id", "language", "status", "logo", "open_time")
SELECT -1, 'ja_JP', '1', 'images/language/japan.png', now() WHERE NOT EXISTS (SELECT "id" FROM site_language WHERE site_id = -1 AND language = 'ja_JP');
-- 站点货币
INSERT INTO site_currency ("site_id", "code", "status")
SELECT -1, 'JPY', '1' WHERE NOT EXISTS (SELECT "id" FROM site_currency WHERE site_id = -1 AND code = 'JPY');
-- 系统货币
INSERT INTO sys_currency (id, code, status, center_id, currency_sign)
SELECT 3, 'JPY', TRUE, -3, '¥' WHERE NOT EXISTS (SELECT "id" FROM sys_currency WHERE code = 'JPY'); | true |
e2a544ca5c29b40e58aa120c6afbe62dd2732f68 | SQL | pedrobonifacio/api_favoriteBooks | /database/createDB.sql | UTF-8 | 334 | 3.296875 | 3 | [] | no_license | create database book;
use book;
CREATE TABLE tb_book (
cd_book INT NOT NULL AUTO_INCREMENT,
vl_rankPosition INT NOT NULL unique,
nm_book VARCHAR(300) NOT NULL,
url_bookCover VARCHAR(2000) NOT NULL,
PRIMARY KEY (`cd_book`)
)ENGINE = InnoDB DEFAULT CHARACTER SET = utf8;
select * from tb_book
order by vl_rankPosition asc; | true |
73bc68626cc74c35242571999f8a6d9eba5fab84 | SQL | nss-day-cohort-18/chinook-taylorperkins | /line_item_track_artist.sql | UTF-8 | 304 | 3.8125 | 4 | [] | no_license | /*
Provide a query that includes the purchased track
name AND artist name with each invoice line item.
*/
SELECT t.Name TrackName, a.Name ArtistName
FROM InvoiceLine il, Track t, Artist a, Album al
WHERE il.Trackid = t.TrackId
AND t.AlbumId = al.AlbumId
AND al.ArtistId = a.ArtistId
ORDER BY a.Name | true |
e0802153b2b40d70a140c12344a371f5dee46e78 | SQL | lehdarren/PL-SQL | /Cursors2.sql | UTF-8 | 465 | 3.328125 | 3 | [] | no_license | DECLARE
lv_total bb_basket.total%TYPE;
BEGIN
SELECT total
INTO lv_total
FROM bb_basket
WHERE idBasket = 17; --throws error
IF SQL%ROWCOUNT > 0 THEN
DBMS_OUTPUT.PUT_LINE('The total is: ' || lv_total);
ELSIF SQL%NOTFOUND THEN
DBMS_OUTPUT.PUT_LINE('Could not find a total');
END IF;
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE('Could not find a total');
END; | true |
885be3f2a414bd1e66ec44f1ddcfcee074da457e | SQL | TihomirIvanovIvanov/SoftUni | /C#DBFundamentals/DB-Basics-MS-SQL-Server/04BuiltInFunctions/BuiltInFunctions/12. Games From 2011 and 2012 Year.sql | UTF-8 | 145 | 3.53125 | 4 | [
"MIT"
] | permissive | SELECT TOP 50 Name, FORMAT(Start, 'yyyy-MM-dd') AS Start
FROM Games
WHERE YEAR(Start) BETWEEN '2011' AND '2012'
ORDER BY Games.Start, Games.Name | true |
827117a1d4f2ceaa31cfec3b2b2174ad1efdeb55 | SQL | Dungcode/Railway19 | /SQL/Assignment 1/Testing_System_Assignment_2.sql | UTF-8 | 8,825 | 3.921875 | 4 | [] | no_license | -- Testing_System_Assignment_2
-- =============>>> Question 1: Tối ưu lại assignment trước ====================
-- =============>>> Question 2: Thêm các constraint vào assignment trước =======
DROP DATABASE IF EXISTS TESTINGMANAGEMENT;
CREATE DATABASE TESTINGMANAGEMENT;
USE TESTINGMANAGEMENT;
-- TABLE 1: Department
CREATE TABLE Department(
DepartmentID TINYINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
DepartmentName VARCHAR(50) NOT NULL UNIQUE KEY
);
-- TABLE 2: Position
CREATE TABLE Position (
PositionID TINYINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
PositionName ENUM('Dev', 'Test','Scrum Master','PM') NOT NULL
);
-- TABLE 3: Account
CREATE TABLE `Account`(
AccountID INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
Email VARCHAR(50) UNIQUE KEY,
Username VARCHAR(50) NOT NULL UNIQUE KEY,
FullName NVARCHAR(50)NOT NULL ,
DepartmentID TINYINT UNSIGNED NOT NULL,
PositionID TINYINT UNSIGNED NOT NULL ,
CreateDate DATETIME ,
FOREIGN KEY (PositionID) REFERENCES Position (PositionID),
FOREIGN KEY (DepartmentID) REFERENCES Department(DepartmentID)
);
-- TABLE 4: Group
CREATE TABLE `Group`(
GroupID TINYINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
GroupName VARCHAR(50) NOT NULL,
CreatorID INT UNSIGNED NOT NULL UNIQUE KEY,
CreateDate DATETIME ,
FOREIGN KEY(CreatorID) REFERENCES`Account`(AccountID)
);
-- TABLE 5: GroupAccount
CREATE TABLE GroupAccount(
GroupID TINYINT UNSIGNED NOT NULL ,
AccountID INT UNSIGNED NOT NULL,
JoinDate DATETIME ,
FOREIGN KEY(GroupID) REFERENCES `Group`(GroupID),
FOREIGN KEY(AccountID)REFERENCES `Account`(AccountID)
);
-- TABLE 6: TypeQuestion
CREATE TABLE TypeQuestion(
TypeID TINYINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
TypeName ENUM('Essay', 'Multiple-Choice')
);
-- TABLE 7: CategoryQuestion
CREATE TABLE CategoryQuestion(
CategoryID TINYINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
CategoryName VARCHAR(50)
);
-- TABLE 8: Question
CREATE TABLE Question(
QuestionID TINYINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
Content VARCHAR(50),
CategoryID TINYINT UNSIGNED,
TypeID TINYINT UNSIGNED,
CreatorID INT UNSIGNED,
CreateDate DATE,
FOREIGN KEY (CreatorID) REFERENCES `Account`(AccountID),
FOREIGN KEY (TypeID) REFERENCES TypeQuestion(TypeID),
FOREIGN KEY (CategoryID) REFERENCES CategoryQuestion(CategoryID)
);
-- TABLE 9: Answer
CREATE TABLE Answer(
AnswerID TINYINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
Content VARCHAR(50),
QuestionID TINYINT UNSIGNED ,
isCorrect ENUM('true','false'),
FOREIGN KEY (QuestionID) REFERENCES Question (QuestionID)
);
-- TABLE 10: Exam
CREATE TABLE Exam(
ExamID TINYINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
`Code` VARCHAR(50) NOT NULL,
Title VARCHAR(50) NOT NULL,
CategoryID INT UNSIGNED,
Duration TINYINT NOT NULL,
CreatorID TINYINT,
CreateDate DATETIME
);
-- TABLE 11: ExamQuestion
CREATE TABLE ExamQuestion(
ExamID TINYINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
QuestionID TINYINT UNSIGNED,
FOREIGN KEY(ExamID) REFERENCES Exam(ExamID),
FOREIGN KEY(QuestionID) REFERENCES Question(QuestionID)
);
-- ===================================================================================
-- =================>>> Question 3: Chuẩn bị data cho bài 3 <<<=======================
-- ============================= INSERT DỮ LIỆU ======================================
-- INSERT INTO Department (DepartmentID, DepartmentName)
-- VALUES
-- TABLE 1: Department
INSERT INTO Department ( DepartmentName )
VALUES ( 'Giám đốc' ),
( 'Thư kí' ),
( 'Nhân sự' ),
( 'Hành Chính' ),
( 'Tài chính' ),
( 'Marketing' ),
( 'Sale' ),
( 'CSKH' ),
( 'Giám sát' ),
( 'Bảo vệ' );
-- TABLE 2: Position
INSERT INTO Position (PositionName )
VALUES ('Dev' ),
('Test' ),
('Scrum Master' ),
('PM' );
-- -- table 3: `Account`
INSERT INTO `Account` ( Email , Username , FullName ,DepartmentID , PositionID , CreateDate )
VALUES ('QuocViet@gmail.com' , 'QuocViet' ,N'Tạ Quốc Việt' , 5 , 1 ,'2021-03-05'),
('ThuyDung@gmail.com' , 'ThuyDung' ,N'Hoàng Thùy Dung' , 8 , 2 ,'2021-03-05'),
('TuanAnh@gmail.com' , 'TuanAnh' ,N'Bùi Tuấn Anh' , 1 , 2 ,'2021-03-07'),
('MinhHieu@gmail.com' , 'MinhHieu' ,N'Phạm Minh Hiếu' , 4 , 4 , DEFAULT ),
('HuyenTrang@gmail.com' , 'HuyenTrang' ,N'Phạm Thị Huyền Trang', 2 , 4 ,'2021-03-10'),
('ĐucManh@gmail.com' , 'ĐucManh' ,N'Lê Đức Mạnh' , 3 , 3 ,'2021-04-05'),
('BichThao@gmail.com' , 'BichThao' ,N'Đỗ Thị Bích Thảo' , 10 , 2 , NULL ),
('LanAnh@gmail.com' , 'LanAnh ' ,N'Chử Thị Lan Anh' , 9 , 1 ,'2021-04-07'),
('VanHoa@gmail.com' , 'VanHoa ' ,N'Trịnh Văn Hóa' , 7 , 2 ,'2021-04-07'),
('MinhTrang@gmail.com' , 'MinhTrang' ,N'Tặng Thị Minh Trang' , 3 , 1 , DEFAULT ),
('ThiKhoe@gmail.com' , 'ThiKhoe ' ,N'Lê Thị Khỏe' , 2 , 1 ,'2021-04-09'),
('HaiCuong@gmail.com' , 'HaiCuong' ,N'Lại Hải Cường' , 5 , 1 ,'2021-03-08');
-- TABLE 4: Group
INSERT INTO `Group` ( GroupName , CreatorID , CreateDate )
VALUES ('Tokyo' , 5 , '2021-08-08'),
('Hà nội' , 1 , '2021-08-07'),
('Hà Tĩnh' , 2 , '2021-08-09'),
('Hải Phòng' , 3 , '2021-08-10'),
('Thái Bình' , 4 , '2021-08-28'),
('Quảng Ninh' , 6 , '2021-09-06'),
('Hòa Bình' , 7 , '2021-09-07'),
('Hà Nam' , 8 , '2021-09-08'),
('osaka ' , 9 , '2021-09-09'),
('Cà Mau ' , 10 , '2021-09-10');
-- TABLE 5: GroupAccount
INSERT INTO `GroupAccount` ( GroupID , AccountID , JoinDate )
VALUES ( 4 , 1 ,'2021-09-05'),
( 2 , 2 ,'2021-09-07'),
( 3 , 3 ,'2021-09-09'),
( 3 , 4 ,'2021-09-10'),
( 5 , 3 ,'2021-10-06'),
( 1 , 7 ,'2021-10-07'),
( 4 , 9 ,'2021-10-09'),
( 6 , 5 ,'2021-10-10');
-- TABLE 6: TypeQuestion
INSERT INTO TypeQuestion ( TypeName )
VALUES ('Essay' ),
('Multiple-Choice' );
-- TABLE 7: CategoryQuestion
INSERT INTO CategoryQuestion ( CategoryName )
VALUES ( 'Java' ),
( 'SQL' ),
( 'Postman' ),
( 'C++' ),
( 'C #' ),
( 'Ruby' );
-- TABLE 8: Question
-- TABLE 8: Question
INSERT INTO Question ( Content , CategoryID, TypeID ,CreatorID , CreateDate )
VALUES ('Câu hỏi về Java' , 1 , 1 , 4 ,'2021-04-05'),
('Câu hỏi về Ruby' , 6 , 2 , 1 ,'2021-04-05'),
('Câu hỏi về C#' , 5 , 1 , 5 ,'2021-04-06'),
('Câu hỏi về C++' , 6 , 1 , 7 ,'2021-04-07'),
('Câu hỏi về SQL' , 5 , 1 , 6 ,'2021-04-03'),
('Câu hỏi về Postman,' , 4 , 2 , 8 ,'2021-04-04');
-- TABLE 9: Answer
INSERT INTO Answer ( Content , QuestionID, isCorrect )
VALUES ('Trả lời 01' , 5 , 'true' ),
('Trả lời 02' , 1 , 'true' ),
('Trả lời 03' , 5 , 'false' ),
('Trả lời 04' , 1 , 'true' ),
('Trả lời 05' , 2 , 'true' ),
('Trả lời 06' , 3 , 'true' );
-- TABLE 10: Exam
INSERT INTO Exam ( `Code` , Title , CategoryID , Duration , CreatorID , CreateDate )
VALUES ('Railway01' , 'Exam C#' , 1 , 60 , 5 , '2021-04-05'),
('Railway02' , 'Exam Ruby' , 6 , 60 , 2 , '2021-04-05'),
('Railway03' , 'Exam C++' , 5 , 120 , 2 , '2021-04-07'),
('Railway00' , 'Exam Java' , 6 , 60 , 3 , '2021-04-08'),
('Railway05' , 'Exam SQL' , 2 , 60 , 7 , '2021-04-05'),
('Railway06' , 'Exam Postman,' , 3 , 60 , 8 , '2021-04-07');
-- TABLE 11: ExamQuestion
INSERT INTO ExamQuestion (ExamID , QuestionID )
VALUES ( 1 , 6 ),
( 2 , 5 ),
( 3 , 4 ),
( 4 , 3 ),
( 5 , 3 ),
( 6 , 6 );
| true |
c52ec061d794dbd1b08af479884c872ddd7968d5 | SQL | DeserveL/taotao | /taotao-dao/src/main/resources/sql/tb_item_desc(商品描述).sql | UTF-8 | 575 | 3.09375 | 3 | [] | no_license | SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for tb_item_desc
-- ----------------------------
DROP TABLE IF EXISTS `tb_item_desc`;
CREATE TABLE `tb_item_desc` (
`item_id` bigint(20) DEFAULT NULL COMMENT '商品ID',
`item_desc` text COMMENT '商品描述',
`created` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`updated` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
KEY `item_id` (`item_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='商品描述表';
| true |
42590f57136b47297378c29f2008290e7ec3ff5b | SQL | DavidAlphaFox/casino_server | /game_server/db/create_table_smxx/task_daily.sql | GB18030 | 957 | 3.359375 | 3 | [] | no_license | -- ----------------------------
-- Table structure for `task_daily`
-- ----------------------------
DROP TABLE IF EXISTS `task_daily`;
CREATE TABLE `task_daily` (
`uid` bigint(20) NOT NULL DEFAULT 0 COMMENT 'id' ,
`type` tinyint(4) NOT NULL DEFAULT 0 COMMENT '' ,
`state` tinyint(4) NOT NULL DEFAULT 0 COMMENT '״̬' ,
`used_trigger_count` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'ʹ' ,
`used_cycle_count` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'ǰһ֣ ʹõĴ' ,
`trigger_count` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'ѽճ' ,
`reset_time` int(17) NOT NULL DEFAULT 0 COMMENT 'ϴʱ' ,
`total` int(17) NOT NULL DEFAULT 0 COMMENT 'ܵɴ' ,
`trigger_time` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT 'ʱ'
)
ENGINE=MyISAM
DEFAULT CHARACTER SET=utf8 COLLATE=utf8_general_ci
COMMENT='ճͳƱ'
; | true |
18b12e865b1adc467e6cda67a3d26dacd8f875fc | SQL | TAAPArthur/SouthwestBot | /Install/Southwest.sql | UTF-8 | 4,148 | 3.78125 | 4 | [
"MIT"
] | permissive | -- phpMyAdmin SQL Dump
-- version 4.7.6
-- https://www.phpmyadmin.net/
--
-- Host: localhost
-- Generation Time: Dec 28, 2017 at 01:14 AM
-- Server version: 10.1.29-MariaDB
-- PHP Version: 7.2.0
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
CREATE USER 'southwest'@'localhost' IDENTIFIED VIA mysql_native_password USING '***';GRANT USAGE ON *.* TO 'southwest'@'localhost' REQUIRE NONE WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0;
GRANT ALL PRIVILEGES ON `Southwest`.* TO 'southwest'@'localhost';
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `Southwest`
--
-- --------------------------------------------------------
--
-- Table structure for table `CheapFlights`
--
CREATE TABLE `CheapFlights` (
`ID` int(11) NOT NULL,
`DepartureTime` datetime NOT NULL,
`FlightNumber` int(11) NOT NULL,
`Price` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Table structure for table `UpcomingFlights`
--
CREATE TABLE `UpcomingFlights` (
`ID` int(11) NOT NULL,
`UserID` int(11) NOT NULL,
`ConfirmationNumber` varchar(15) COLLATE utf8mb4_unicode_ci NOT NULL,
`FlightNumber` int(11) NOT NULL,
`DepartureTime` datetime NOT NULL,
`ArrivalTime` datetime NOT NULL,
`Title` tinytext COLLATE utf8mb4_unicode_ci NOT NULL,
`Origin` varchar(12) COLLATE utf8mb4_unicode_ci NOT NULL,
`Dest` varchar(12) COLLATE utf8mb4_unicode_ci NOT NULL,
`StartDate` tinyint(4) DEFAULT NULL,
`EndDate` tinyint(4) DEFAULT NULL,
`Price` decimal(5,2) DEFAULT NULL,
`Active` tinyint(1) NOT NULL DEFAULT '1',
`LastUpdated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Table structure for table `Users`
--
CREATE TABLE `Users` (
`ID` int(11) NOT NULL,
`Username` varchar(30) NOT NULL,
`Password` tinytext NOT NULL,
`FirstName` tinytext NOT NULL,
`LastName` tinytext NOT NULL,
`TelegramChatID` int(11) DEFAULT NULL,
`StartDateDefaultDelta` tinyint(3) NOT NULL DEFAULT '3',
`EndDateDefaultDelta` tinyint(3) NOT NULL DEFAULT '3',
`PriceDelta` decimal(5,2) NOT NULL DEFAULT '10.00',
`MinPrice` decimal(5,2) NOT NULL DEFAULT '200.00'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Indexes for dumped tables
--
--
-- Indexes for table `CheapFlights`
--
ALTER TABLE `CheapFlights`
ADD PRIMARY KEY (`ID`),
ADD UNIQUE KEY `Date` (`DepartureTime`,`FlightNumber`);
--
-- Indexes for table `UpcomingFlights`
--
ALTER TABLE `UpcomingFlights`
ADD PRIMARY KEY (`ID`),
ADD UNIQUE KEY `UserID` (`UserID`,`FlightNumber`,`DepartureTime`);
--
-- Indexes for table `Users`
--
ALTER TABLE `Users`
ADD PRIMARY KEY (`ID`),
ADD UNIQUE KEY `CrunchyrollUsername` (`Username`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `CheapFlights`
--
ALTER TABLE `CheapFlights`
MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=283;
--
-- AUTO_INCREMENT for table `UpcomingFlights`
--
ALTER TABLE `UpcomingFlights`
MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=16;
--
-- Constraints for dumped tables
--
--
-- Constraints for table `UpcomingFlights`
--
ALTER TABLE `UpcomingFlights`
ADD CONSTRAINT `UpcomingFlights_ibfk_1` FOREIGN KEY (`UserID`) REFERENCES `Users` (`ID`) ON DELETE CASCADE ON UPDATE CASCADE;
--
-- Constraints for table `Users`
--
ALTER TABLE `Users`
ADD CONSTRAINT `Users_ibfk_1` FOREIGN KEY (`ID`) REFERENCES `TAAPArthur`.`Accounts` (`ID`) ON DELETE CASCADE ON UPDATE CASCADE;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
| true |
c0feb3a057d5546431c579cb95d5c3924245a215 | SQL | acoussemaeker/BibliothequeAudio | /Autre/BDD/bibliothequeaudio.sql | UTF-8 | 3,406 | 3.296875 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 4.1.14
-- http://www.phpmyadmin.net
--
-- Client : 127.0.0.1
-- Généré le : Jeu 01 Octobre 2015 à 14:26
-- Version du serveur : 5.6.17
-- Version de PHP : 5.5.12
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
--
-- Base de données : `bibliothequeaudio`
--
-- --------------------------------------------------------
--
-- Structure de la table `audio`
--
CREATE TABLE IF NOT EXISTS `audio` (
`Id` int(11) NOT NULL AUTO_INCREMENT,
`Nom` varchar(20) NOT NULL,
`Emplacement` varchar(20) NOT NULL,
PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
--
-- Contenu de la table `audio`
--
INSERT INTO `audio` (`Id`, `Nom`, `Emplacement`) VALUES
(1, 'bouh', 'c:/test/'),
(2, 'baah', 'c:/test/');
-- --------------------------------------------------------
--
-- Structure de la table `playlist`
--
CREATE TABLE IF NOT EXISTS `playlist` (
`Id` int(11) NOT NULL AUTO_INCREMENT,
`UserId` int(11) NOT NULL,
`Nom` varchar(20) NOT NULL,
PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Structure de la table `playlistaudio`
--
CREATE TABLE IF NOT EXISTS `playlistaudio` (
`Id` int(11) NOT NULL AUTO_INCREMENT,
`PlayListId` int(11) NOT NULL,
`UserAudioId` int(11) NOT NULL,
`Place` int(11) NOT NULL,
PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Structure de la table `requestaudio`
--
CREATE TABLE IF NOT EXISTS `requestaudio` (
`Id` int(20) NOT NULL AUTO_INCREMENT,
`IdUser` int(11) NOT NULL,
`Nom` varchar(50) DEFAULT NULL,
`Emplacement` varchar(100) DEFAULT NULL,
PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
--
-- Contenu de la table `requestaudio`
--
INSERT INTO `requestaudio` (`Id`, `IdUser`, `Nom`, `Emplacement`) VALUES
(1, 1, 'banboulala', 'C:/enAttente/'),
(2, 2, 'bidoula', 'C:/enAttente/');
-- --------------------------------------------------------
--
-- Structure de la table `user`
--
CREATE TABLE IF NOT EXISTS `user` (
`Id` int(11) NOT NULL AUTO_INCREMENT,
`Pseudo` varchar(20) NOT NULL,
`Password` varchar(20) NOT NULL,
`Mail` varchar(50) NOT NULL,
`Grade` tinyint(1) NOT NULL,
PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
--
-- Contenu de la table `user`
--
INSERT INTO `user` (`Id`, `Pseudo`, `Password`, `Mail`, `Grade`) VALUES
(1, 'gertrude', 'boul', 'gertrude.hg@gmail.co', 0),
(2, 'robert', 'test', 'robert.trypo@gmail.c', 0);
-- --------------------------------------------------------
--
-- Structure de la table `useraudio`
--
CREATE TABLE IF NOT EXISTS `useraudio` (
`Id` int(11) NOT NULL AUTO_INCREMENT,
`UserId` int(11) NOT NULL,
`AudioID` int(11) NOT NULL,
`Temps` time NOT NULL,
PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
| true |
8f23efe0fe1f7a89cfc4d8674567c552a8e95620 | SQL | mehedisayed/Laravel_Project | /sql/laravelproject.sql | UTF-8 | 7,811 | 3.234375 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 4.9.0.1
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: May 26, 2020 at 07:10 PM
-- Server version: 10.4.6-MariaDB
-- PHP Version: 7.3.8
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `laravelproject`
--
-- --------------------------------------------------------
--
-- Table structure for table `category`
--
CREATE TABLE `category` (
`cid` int(11) NOT NULL,
`cname` varchar(25) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `category`
--
INSERT INTO `category` (`cid`, `cname`) VALUES
(1, 'Men'),
(2, 'Women'),
(3, 'Children');
-- --------------------------------------------------------
--
-- Table structure for table `favourite`
--
CREATE TABLE `favourite` (
`fid` int(11) NOT NULL,
`iid` int(11) NOT NULL,
`uid` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `item`
--
CREATE TABLE `item` (
`iid` int(11) NOT NULL,
`iname` varchar(100) NOT NULL,
`iprice` float NOT NULL,
`scid` int(11) NOT NULL,
`description` varchar(500) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `item`
--
INSERT INTO `item` (`iid`, `iname`, `iprice`, `scid`, `description`) VALUES
(1, 'DRESS SHIRT', 2280, 1, '95% Cotton 5% Spandex'),
(2, 'CONTRASTING COLLAR DRESS SHIRT', 2599, 1, 'Slim fit shirt with lapel collar and long sleeves with buttoned cuffs.'),
(3, 'TANJIM SQUAD RUBBERIZED PRINT T-SHIRT', 1999, 2, 'T-Shirt with round neck and short sleeves. Rubberized Squad print.'),
(4, 'BLACK TEES WITH NEON PRINT', 2289, 2, '95% Cotton 5% Spandex'),
(5, 'GREY CHECK SUIT', 7833, 3, 'Blazer with pointed lapel collar with removable pin and long sleeves with buttoned cuffs. Welt pocket at chest and flap pockets at hip. Interior pocket. Double back vent. Front button closure. Slim fit pants with front pockets and buttoned back welt pockets. Front zip and button closure.'),
(6, 'LIGHT WEIGHT CHECKED BLAZER', 5999, 3, 'Blazer with pointed lapel collar with removable pin and long sleeves with buttoned cuffs. Welt pocket at chest and flap pockets at hip. Interior pocket. Double back vent. Front button closure.');
-- --------------------------------------------------------
--
-- Table structure for table `orderitem`
--
CREATE TABLE `orderitem` (
`otid` int(11) NOT NULL,
`iid` int(11) NOT NULL,
`quantity` int(11) NOT NULL,
`price` float NOT NULL,
`olid` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `orderlog`
--
CREATE TABLE `orderlog` (
`olid` int(11) NOT NULL,
`uid` int(11) NOT NULL,
`date` date NOT NULL,
`status` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `orderlog`
--
INSERT INTO `orderlog` (`olid`, `uid`, `date`, `status`) VALUES
(1, 2, '2020-05-14', 'Payment Pendding'),
(2, 2, '2020-05-06', 'Shipping Ready'),
(3, 2, '2020-05-09', 'Shipping Ready'),
(4, 2, '2020-05-04', 'Payment Pendding'),
(5, 2, '2020-05-15', 'Completed');
-- --------------------------------------------------------
--
-- Table structure for table `payment`
--
CREATE TABLE `payment` (
`pid` int(11) NOT NULL,
`date` date NOT NULL,
`amount` float NOT NULL,
`status` varchar(15) NOT NULL,
`olid` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `payment`
--
INSERT INTO `payment` (`pid`, `date`, `amount`, `status`, `olid`) VALUES
(1, '2020-05-14', 10000, 'Pendding', 1),
(2, '2020-05-14', 10000, 'Completed', 2),
(3, '2020-05-11', 10000, 'Completed', 3),
(4, '2020-05-15', 10000, 'Pendding', 4),
(5, '2020-05-14', 10000, 'Completed', 5);
-- --------------------------------------------------------
--
-- Table structure for table `subcategory`
--
CREATE TABLE `subcategory` (
`scid` int(11) NOT NULL,
`scname` varchar(25) NOT NULL,
`cid` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `subcategory`
--
INSERT INTO `subcategory` (`scid`, `scname`, `cid`) VALUES
(1, 'Shirts', 1),
(2, 'T shirts', 1),
(3, 'Blazer & Suits', 1),
(4, 'Joggers', 1),
(5, 'Jeans', 1),
(6, 'Long Shirts', 2),
(7, 'Shrugs', 2),
(8, 'Ethnic Tops', 2),
(9, 'Bottoms', 2),
(10, 'Scarves', 2),
(11, 'Dress', 2),
(12, 'Bags', 2);
-- --------------------------------------------------------
--
-- Table structure for table `user`
--
CREATE TABLE `user` (
`uid` int(11) NOT NULL,
`uname` varchar(26) NOT NULL,
`email` varchar(50) NOT NULL,
`password` varchar(15) NOT NULL,
`phone` int(11) NOT NULL,
`gender` varchar(10) NOT NULL,
`role` varchar(20) NOT NULL,
`address` varchar(100) NOT NULL,
`status` varchar(20) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `user`
--
INSERT INTO `user` (`uid`, `uname`, `email`, `password`, `phone`, `gender`, `role`, `address`, `status`) VALUES
(1, 'Mehedi Sayed', 'sayedmehedi@hotmail.com', '12345678', 1731569019, 'Male', 'Admin', 'Dhaka,Bangladesh', 'Active'),
(2, 'Mehrab', 'mehrab@gmail.com', '12345678', 1731569019, 'Male', 'Customer', 'Lakshmipur,Bangladesh', 'Active'),
(3, 'Mahbub', 'sm@gmail.com', '12345678', 1629438110, 'Male', 'Manager', 'Dhaka', 'Active'),
(4, 'Shakill Ahmed', 'shakill@gmail.com', '12345678', 1629438110, 'Male', 'Employee', 'Dhaka', 'Active'),
(6, 'admin', 'admin@gmail.com', '12345678', 1629438110, 'Male', 'Admin', 'Dhaka', 'Active');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `category`
--
ALTER TABLE `category`
ADD PRIMARY KEY (`cid`);
--
-- Indexes for table `favourite`
--
ALTER TABLE `favourite`
ADD PRIMARY KEY (`fid`);
--
-- Indexes for table `item`
--
ALTER TABLE `item`
ADD PRIMARY KEY (`iid`);
--
-- Indexes for table `orderitem`
--
ALTER TABLE `orderitem`
ADD PRIMARY KEY (`otid`);
--
-- Indexes for table `orderlog`
--
ALTER TABLE `orderlog`
ADD PRIMARY KEY (`olid`);
--
-- Indexes for table `payment`
--
ALTER TABLE `payment`
ADD PRIMARY KEY (`pid`);
--
-- Indexes for table `subcategory`
--
ALTER TABLE `subcategory`
ADD PRIMARY KEY (`scid`);
--
-- Indexes for table `user`
--
ALTER TABLE `user`
ADD PRIMARY KEY (`uid`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `category`
--
ALTER TABLE `category`
MODIFY `cid` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
--
-- AUTO_INCREMENT for table `favourite`
--
ALTER TABLE `favourite`
MODIFY `fid` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `item`
--
ALTER TABLE `item`
MODIFY `iid` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8;
--
-- AUTO_INCREMENT for table `orderitem`
--
ALTER TABLE `orderitem`
MODIFY `otid` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `orderlog`
--
ALTER TABLE `orderlog`
MODIFY `olid` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
--
-- AUTO_INCREMENT for table `payment`
--
ALTER TABLE `payment`
MODIFY `pid` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
--
-- AUTO_INCREMENT for table `subcategory`
--
ALTER TABLE `subcategory`
MODIFY `scid` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=14;
--
-- AUTO_INCREMENT for table `user`
--
ALTER TABLE `user`
MODIFY `uid` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
| true |
bc007a9d6f447f3f189bcf9d1bdc5002dc716f62 | SQL | ahnan4arch/blimp | /ddl/file_elements.ddl | UTF-8 | 402 | 2.8125 | 3 | [] | no_license | CREATE TABLE file_elements (
file_id INTEGER PRIMARY KEY,
location_id INTEGER NOT NULL REFERENCES indexed_locations(location_id) ON UPDATE RESTRICT ON DELETE RESTRICT,
content_id INTEGER NOT NULL REFERENCES file_contents(content_id) ON UPDATE RESTRICT ON DELETE RESTRICT,
file_size INTEGER NOT NULL,
modified_date TEXT NOT NULL
);
| true |
190daedb681b7d23dbc11e2f84d62c230fcd51d3 | SQL | LannyYao/partition | /src/main/resources/db/migration/V1_3__key.sql | UTF-8 | 285 | 2.921875 | 3 | [] | no_license | create table IF NOT EXISTS user_key_partition(
id int,
name varchar(10),
PRIMARY KEY (id)
)
PARTITION BY KEY()
PARTITIONS 2;
-- 基于给定的分区个数,将数据分配到不同分区,HASH分区只能对整数进行分区,对于非整型字段只能通过表达式转为整型 | true |
e322eef3b6c9f03e9c743d2430ff3e239b51de31 | SQL | eeszy/movie-website | /queries.sql | UTF-8 | 540 | 3.890625 | 4 | [] | no_license | SELECT DISTINCT CONCAT(first,' ', last) as actorname from Actor as a, Movie as m, MovieActor as ma where a.id = ma.aid and m.id = ma.mid and m.title = 'Death to Smoochy';
SELECT COUNT(id) from (SELECT id ,count(mid) from Director join MovieDirector on id = did group by id having COUNT(mid) >= 4) as T;
-- all the titles of movies which are released after 2000
SELECT title from Movie where year > 2002;
-- find the movie which has the hightest IMDb rating
SELECT * from MovieRating where imdb >= all (SELECT imdb from MovieRating);
| true |
d8b87e2330cdd18dacb2bfeafe657b0eb6c5bbb8 | SQL | winea/Joblist_PHP_OOP | /libs/joblist_sqlExemplo.sql | UTF-8 | 798 | 4.03125 | 4 | [] | no_license | drop TABLE tbl_categories;
CREATE TABLE tbl_categories(id_categ int(11) PRIMARY KEY AUTO_INCREMENT, name varchar(255) NOT NULL);
CREATE TABLE tbl_jobs(id_job int(11) PRIMARY KEY AUTO_INCREMENT, company varchar(255) NOT null, job_title varchar(255) NOT NULL,
description varchar(255) NOT null, salary varchar(100) NOT null, location varchar(255) NOT NULL,
contact_user varchar(255) NOT null, contact_email varchar(255) NOT NULL,
id_categ int(11) NOT NULL,
FOREIGN KEY(id_categ) REFERENCES tbl_categories(id_categ));
SELECT tbl_jobs.*, tbl_categories.name AS cname
FROM tbl_jobs
INNER JOIN tbl_categories
ON tbl_jobs.id_categ = tbl_categories.id_categ
ORDER BY post_date DESC" | true |
4e4593bf3cb1ae52b459910e94f3c46d82ba9db4 | SQL | lsh0721/springboot-demo | /doc/table.sql | UTF-8 | 1,361 | 3.359375 | 3 | [] | no_license | CREATE TABLE `city_info`
(
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(32) DEFAULT NULL,
`state` varchar(32) DEFAULT NULL,
`country` varchar(32) DEFAULT NULL,
PRIMARY KEY (`ID`)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8;
INSERT INTO `city_info` (`name`, `state`, `country`)
VALUES ('北京', 'BJ0001', 'CH01'),
('上海', 'SH0001', 'CH02'),
('广州', 'GD0001', 'CH03'),
('深圳', 'GD0002', 'CH04'),
('天津', 'TJ0001', 'CH05'),
('南京', 'JS0001', 'CH06'),
('杭州', 'ZJ0001', 'CH07'),
('苏州', 'JS0002', 'CH08'),
('武汉', 'HB0001', 'CH09'),
('成都', 'SC0001', 'CH10');
CREATE TABLE `user_info`
(
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_name` varchar(32) DEFAULT NULL,
`address` varchar(32) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8;
INSERT INTO `user_info` (`user_name`, `address`)
VALUES ('唐三藏', '长安'),
('孙悟空', '花果山'),
('猪八戒', '高老庄'),
('沙悟净', '流沙河'),
('观音', '南海'),
('如来', '灵山'),
('玉帝', '云霄殿'),
('菩提祖师', '三星洞'),
('镇元子', '五庄观'),
('太上老君', '兜率宫')
;
create unique index ui_user_info_user_name ON user_info(
user_name asc
); | true |
b37bd26d79b2021a9fb7950955aaa1db03216b95 | SQL | radtek/oracle-administration-scripts | /recommended_min_undo_size_for_that_moment.sql | UTF-8 | 345 | 3.140625 | 3 | [] | no_license | --ALTER SYSTEM SET UNDO_RETENTION = 9000;
SELECT ((UR*(UPS*DBS))+(DBS*24))/1048576 AS "Recomended UNDO TBS SIZE in MB" FROM (SELECT value AS UR FROM v$parameter WHERE name='undo_retention'),
(SELECT (SUM(undoblks)/SUM(((end_time-begin_time)*86400))) AS UPS FROM v$undostat),
(SELECT value AS DBS FROM v$parameter WHERE name='db_block_size'); | true |
de300f20c4bd5f1e93766c3d7f3ee63a1cd11151 | SQL | bebo-eggo/compiere-eggo | /compiere-custo-eurocenter/.svn/pristine/de/de300f20c4bd5f1e93766c3d7f3ee63a1cd11151.svn-base | UTF-8 | 3,277 | 3.421875 | 3 | [] | no_license | CREATE OR REPLACE FORCE VIEW "AD_TAB_V"
AS
SELECT t.AD_Tab_ID AS AD_Tab_ID,
t.AD_Window_ID AS AD_Window_ID,
t.AD_Table_ID AS AD_Table_ID,
t.AD_CtxArea_ID AS AD_CtxArea_ID,
uw.AD_Role_ID AS UserDef_Role_ID,
uw.AD_User_ID AS AD_User_ID,
uw.AD_UserDef_Win_ID AS AD_UserDef_Win_ID,
uw.CustomizationName AS CustomizationName,
u.AD_UserDef_Tab_ID AS AD_UserDef_Tab_ID,
COALESCE(u.Name,t.Name) AS Name,
COALESCE(u.Description,t.Description) AS Description,
COALESCE(u.Help,t.Help) AS Help,
COALESCE(u.SeqNo,t.SeqNo) AS SeqNo,
COALESCE(u.IsSingleRow,t.IsSingleRow) AS IsSingleRow,
t.HasTree AS HasTree,
t.IsInfoTab AS IsInfoTab,
t.Referenced_Tab_ID AS Referenced_Tab_ID,
tbl.ReplicationType AS ReplicationType,
tbl.TableName AS TableName,
tbl.AccessLevel AS AccessLevel,
tbl.IsSecurityEnabled AS IsSecurityEnabled,
tbl.IsDeleteable AS IsDeleteable,
tbl.IsHighVolume AS IsHighVolume,
tbl.IsView AS IsView,
t.IsTranslationTab AS IsTranslationTab,
COALESCE(u.IsReadOnly,t.IsReadOnly) AS IsReadOnly,
t.AD_Image_ID AS AD_Image_ID,
t.TabLevel AS TabLevel,
t.WhereClause AS WhereClause,
t.OrderByClause AS OrderByClause,
t.CommitWarning AS CommitWarning,
COALESCE(u.ReadOnlyLogic,t.ReadOnlyLogic) AS ReadOnlyLogic,
COALESCE(u.IsDisplayed,t.IsDisplayed) AS IsDisplayed,
COALESCE(u.DisplayLogic,t.DisplayLogic) AS DisplayLogic,
t.AD_Column_ID AS AD_Column_ID,
c.ColumnName AS LinkColumnName,
t.AD_Process_ID AS AD_Process_ID,
t.IsSortTab AS IsSortTab,
t.IsAdvancedTab AS IsAdvancedTab,
COALESCE(u.IsInsertRecord,t.IsInsertRecord) AS IsInsertRecord,
t.AD_ColumnSortOrder_ID AS AD_ColumnSortOrder_ID,
t.AD_ColumnSortYesNo_ID AS AD_ColumnSortYesNo_ID,
t.Included_Tab_ID AS Included_Tab_ID,
t.AD_QuickInfo_ID AS AD_QuickInfo_ID
FROM AD_Tab t
INNER JOIN AD_Table tbl
ON (t.AD_Table_ID = tbl.AD_Table_ID)
LEFT OUTER JOIN AD_Column c
ON (t.AD_Column_ID=c.AD_Column_ID)
LEFT OUTER JOIN AD_UserDef_Tab u
ON (u.AD_Tab_ID=t.AD_Tab_ID)
LEFT OUTER JOIN AD_UserDef_Win uw
ON (uw.AD_UserDef_Win_ID=u.AD_UserDef_Win_ID)
WHERE t.IsActive ='Y'
AND tbl.IsActive ='Y';
/ | true |
017bbd6f99a5faabf17d9b2e3c196cb5e3775944 | SQL | qumino2/Git_Your_SQL | /SQL_Advanced_book_MICK/Ch1/1-2_Self_Join/分地区排序.sql | UTF-8 | 718 | 4.1875 | 4 | [] | no_license | -- P36 练习题1-2-2
--窗口函数解法
select
district,
name,
price,
rank() over (partition by district
order by price desc) as rank_1
from DistrictProducts
--标量子查询解法
select
P1.district,
P1.name,
P1.price,
(select
count(P2.price)
from DistrictProducts P2
where P2.district = P1.district
and P2.price > P1.price) + 1 as rank_1
from DistrictProducts P1;
--用自连接解法
select
P1.district,
P1.name,
max(P1.price),
count(P2.price) + 1 as rank_1
from DistrictProducts P1 left outer join DistrictProducts P2
where P1.district = P2.district
and P1.price < P2.price
group by P1.district, P1.name;
| true |
2641c0c2c9c31b787d86d25fc4ce574e9d0fefe6 | SQL | HustinKava/Employee-Tracker | /DB/seed.sql | UTF-8 | 4,795 | 3.21875 | 3 | [
"MIT"
] | permissive | -- Departments
INSERT into department (name) VALUES ("Finance & Accounting");
INSERT into department (name) VALUES ("Human Resources");
INSERT into department (name) VALUES ("Contracts");
INSERT into department (name) VALUES ("Purchasing");
INSERT into department (name) VALUES ("Planning");
INSERT into department (name) VALUES ("IT");
-- Managers
INSERT into roles (title, salary, department_id) VALUES ("Finance Manager", 127990, 1);
INSERT into roles (title, salary, department_id) VALUES ("Human Resources Manager", 73248, 2);
INSERT into roles (title, salary, department_id) VALUES ("Contracts Manager", 95865, 3);
INSERT into roles (title, salary, department_id) VALUES ("Purchasing Manager", 98783, 4);
INSERT into roles (title, salary, department_id) VALUES ("Planning Manager", 82078, 5);
INSERT into roles (title, salary, department_id) VALUES ("IT Manager", 96785, 6);
-- Finance
INSERT into roles (title, salary, department_id) VALUES ("Accountant", 77317, 1);
INSERT into roles (title, salary, department_id) VALUES ("Payroll", 52000, 1);
INSERT into roles (title, salary, department_id) VALUES ("Data Entry", 35571, 1);
-- Human Resources
INSERT into roles (title, salary, department_id) VALUES ("Administrator", 42421, 2);
INSERT into roles (title, salary, department_id) VALUES ("Coordinator", 32355, 2);
-- Contracts
INSERT into roles (title, salary, department_id) VALUES ("Contracts Clerk", 43217, 3);
-- Purchasing
INSERT into roles (title, salary, department_id) VALUES ("Purchasing", 52068, 4);
INSERT into roles (title, salary, department_id) VALUES ("Purchasing Clerk", 35824, 4);
-- Planning
INSERT into roles (title, salary, department_id) VALUES ("Civil Engineer", 66710, 5);
INSERT into roles (title, salary, department_id) VALUES ("Electrical Engineer", 63662, 5);
INSERT into roles (title, salary, department_id) VALUES ("Mechanical Engineer", 65927, 5);
-- IT
INSERT into roles (title, salary, department_id) VALUES ("Programming Engineer", 85241, 6);
INSERT into roles (title, salary, department_id) VALUES ("Service Desk", 42027, 6);
INSERT into roles (title, salary, department_id) VALUES ("Network Administrator", 74592, 6);
INSERT into roles (title, salary, department_id) VALUES ("Cyber Security", 87371, 6);
-- Manager Names
INSERT into employee (first_name, last_name, roles_id, manager_id) VALUES ("Sandra", "Williams", 1, NULL);
INSERT into employee (first_name, last_name, roles_id, manager_id) VALUES ("Elena", "Mushyan", 2, NULL);
INSERT into employee (first_name, last_name, roles_id, manager_id) VALUES ("Lia", "Kirchner", 3, NULL);
INSERT into employee (first_name, last_name, roles_id, manager_id) VALUES ("Lorraine", "Wray", 4, NULL);
INSERT into employee (first_name, last_name, roles_id, manager_id) VALUES ("Nikephoros", "Labriola", 5, NULL);
INSERT into employee (first_name, last_name, roles_id, manager_id) VALUES ("Olaug", "McFee", 6, NULL);
-- Finance Names
INSERT into employee (first_name, last_name, roles_id, manager_id) VALUES ("Bess", "Cobb", 7, 1);
INSERT into employee (first_name, last_name, roles_id, manager_id) VALUES ("Davis", "Niles", 8, 1);
INSERT into employee (first_name, last_name, roles_id, manager_id) VALUES ("Hiba", "Abbey", 9, 1);
-- Human Resources Names
INSERT into employee (first_name, last_name, roles_id, manager_id) VALUES ("Disha", "Albertson", 10, 2);
INSERT into employee (first_name, last_name, roles_id, manager_id) VALUES ("Ashanti", "Maes", 11, 2);
-- Contracts Names
INSERT into employee (first_name, last_name, roles_id, manager_id) VALUES ("Abdülhamit", " Abano", 12, 3);
-- Purchasing Names
INSERT into employee (first_name, last_name, roles_id, manager_id) VALUES ("Shanon", "Vogel", 13, 4);
INSERT into employee (first_name, last_name, roles_id, manager_id) VALUES ("Shprintze", "Albert", 14, 4);
-- Planning Names
INSERT into employee (first_name, last_name, roles_id, manager_id) VALUES ("Brita", "Firmin", 15, 5);
INSERT into employee (first_name, last_name, roles_id, manager_id) VALUES ("Kaety", "Terzic", 16, 5);
INSERT into employee (first_name, last_name, roles_id, manager_id) VALUES ("Gugulethu", "Jarrett", 17, 5);
-- IT Names
INSERT into employee (first_name, last_name, roles_id, manager_id) VALUES ("Carpus", "Kumar", 18, 6);
INSERT into employee (first_name, last_name, roles_id, manager_id) VALUES ("Þórunn", "Zientek", 19, 6);
INSERT into employee (first_name, last_name, roles_id, manager_id) VALUES ("Dagmar", "Jusić", 20, 6);
INSERT into employee (first_name, last_name, roles_id, manager_id) VALUES ("Tage", "Arbeid", 21, 6);
SELECT * FROM department;
SELECT * FROM roles;
SELECT * FROM employee;
-- SELECT first_name, last_name, roles_id, manager_id
-- FROM employee
-- INNER JOIN roles ON employee.manager_id = employee.id;
-- SOURCE DB/schema.sql | true |
b7171043708e4a546613e93c2e01843d8e2008a5 | SQL | VadimAcosta/dvdrental_questions | /dvd_db_intermediate_questions/dvd_db_intermediate_question_1.sql | UTF-8 | 379 | 4.1875 | 4 | [] | no_license | -- Find the names and the payment amounts for customers
-- with a lifetime purchase amount of greater than $150
SELECT
(customer.customer_id),
customer.first_name ||' '||customer.last_name as "customer_name",
SUM (payment.amount)
FROM customer
LEFT JOIN payment
ON customer.customer_id = payment.customer_id
GROUP BY 1
HAVING sum(payment.amount) > 150
ORDER BY 3 DESC;
| true |
5a571db416160d56d0f93b3b0fcb9b6b3e1353c1 | SQL | radwanromy/github-upload | /PLSQL BFILE 02.sql | UTF-8 | 495 | 2.515625 | 3 | [] | no_license | /* Formatted on 25/Oct/21 10:45:43 PM (QP5 v5.287) */
CREATE OR REPLACE PROCEDURE load_emp_bfile (p_file_loc IN VARCHAR2)
IS
v_file BFILE;
v_filename VARCHAR2 (16);
v_file_exists BOOLEAN;
CURSOR emp_cursor IS
BEGIN
FOR emp_record IN emp_cursor LOOP
v_filename := emp_record.first_name || '.bmp';
v_file := BFILENAME (p_file_loc, v_filename);
v_file_exists := (DBMS_LOB.FILEEXISTS(v_file) = 1);
IF v_file_exists THEN
DBMS_LOB.FILEOPEN (v_file); | true |
73b49c3e3a91479f73f2cd9250c6b3a51e8dd319 | SQL | liumiaowilson/world | /data/import_quest.sql | UTF-8 | 584 | 3.078125 | 3 | [] | no_license | CREATE TABLE IF NOT EXISTS `quest_defs` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(20) NOT NULL,
`content` varchar(200) NOT NULL,
`pay` int(11) NOT NULL,
PRIMARY KEY (`id`)
) DEFAULT CHARSET=utf8 AUTO_INCREMENT=5 ;
ALTER TABLE quest_defs ADD INDEX (name);
CREATE TABLE IF NOT EXISTS `quests` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`def_id` int(11) NOT NULL,
`name` varchar(20) NOT NULL,
`content` varchar(400) NOT NULL,
`time` bigint(20) NOT NULL,
PRIMARY KEY (`id`)
) DEFAULT CHARSET=utf8 AUTO_INCREMENT=5 ;
ALTER TABLE quests ADD INDEX (name);
| true |
22af7af4fdd94e96fa35c1c03ff623d4598263e0 | SQL | silence-do-good/stress-test-Postgres-and-MySQL | /dump/low/day12/select2116.sql | UTF-8 | 191 | 2.734375 | 3 | [] | no_license |
SELECT timeStamp, temperature
FROM ThermometerObservation
WHERE timestamp>'2017-11-11T21:16:00Z' AND timestamp<'2017-11-12T21:16:00Z' AND SENSOR_ID='7cd2eb1a_bec5_4e3f_ba5b_779b1517b4d9'
| true |
3e270d93f6f5c44fc902461f37c5679b4ed57518 | SQL | zou333/zouchu | /www.333.com/0201_shop_db.sql | UTF-8 | 24,968 | 3.09375 | 3 | [] | no_license | /*
Navicat MySQL Data Transfer
Source Server : 0201
Source Server Version : 50617
Source Host : localhost:3306
Source Database : 0201_shop_db
Target Server Type : MYSQL
Target Server Version : 50617
File Encoding : 65001
Date: 2017-06-16 13:10:56
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for admin
-- ----------------------------
DROP TABLE IF EXISTS `admin`;
CREATE TABLE `admin` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`user_name` varchar(18) NOT NULL,
`password` varchar(32) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `id_UNIQUE` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of admin
-- ----------------------------
INSERT INTO `admin` VALUES ('1', 'admin', '21232f297a57a5a743894a0e4a801fc3');
INSERT INTO `admin` VALUES ('2', '123', '123');
INSERT INTO `admin` VALUES ('3', '456', 'e10adc3949ba59abbe56e057f20f883e');
-- ----------------------------
-- Table structure for brand
-- ----------------------------
DROP TABLE IF EXISTS `brand`;
CREATE TABLE `brand` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`brand_name` char(20) NOT NULL,
`content` text NOT NULL,
`image` varchar(300) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `id_UNIQUE` (`id`),
UNIQUE KEY `drand_name_UNIQUE` (`brand_name`)
) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of brand
-- ----------------------------
INSERT INTO `brand` VALUES ('8', '小米', '', '');
INSERT INTO `brand` VALUES ('9', 'oppo', '', '');
INSERT INTO `brand` VALUES ('10', '华为', '', '');
INSERT INTO `brand` VALUES ('12', 'hshhh', '', '');
INSERT INTO `brand` VALUES ('13', '青木', '', '');
INSERT INTO `brand` VALUES ('14', '品牌', '<p>言<br/></p>', '');
-- ----------------------------
-- Table structure for category
-- ----------------------------
DROP TABLE IF EXISTS `category`;
CREATE TABLE `category` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`cate_name` char(10) NOT NULL,
`parent_id` int(10) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
UNIQUE KEY `id_UNIQUE` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of category
-- ----------------------------
INSERT INTO `category` VALUES ('1', '连衣裙', '0');
INSERT INTO `category` VALUES ('2', '外套', '0');
INSERT INTO `category` VALUES ('4', '羊毛衫', '0');
INSERT INTO `category` VALUES ('5', '迷你伞', '2');
INSERT INTO `category` VALUES ('6', '普通伞', '5');
INSERT INTO `category` VALUES ('7', '迷你太阳伞', '5');
INSERT INTO `category` VALUES ('8', '小清新', '7');
INSERT INTO `category` VALUES ('15', '上装', '0');
-- ----------------------------
-- Table structure for category2
-- ----------------------------
DROP TABLE IF EXISTS `category2`;
CREATE TABLE `category2` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`cate_name` varchar(255) NOT NULL,
`parent_id` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of category2
-- ----------------------------
INSERT INTO `category2` VALUES ('1', '手机', '0');
INSERT INTO `category2` VALUES ('2', '智能手机', '1');
-- ----------------------------
-- Table structure for comment
-- ----------------------------
DROP TABLE IF EXISTS `comment`;
CREATE TABLE `comment` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`content` char(255) NOT NULL,
`level` tinyint(3) unsigned zerofill NOT NULL DEFAULT '005',
`user_id` int(10) unsigned zerofill NOT NULL,
`goods_id` int(10) unsigned zerofill NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `id_UNIQUE` (`id`),
KEY `fk_comment_user1_idx` (`user_id`),
KEY `fk_comment_0201_goods1_idx` (`goods_id`),
CONSTRAINT `fk_comment_0201_goods1` FOREIGN KEY (`goods_id`) REFERENCES `goods` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT `fk_comment_user1` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of comment
-- ----------------------------
-- ----------------------------
-- Table structure for contact
-- ----------------------------
DROP TABLE IF EXISTS `contact`;
CREATE TABLE `contact` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`address` varchar(255) NOT NULL,
`phone` bigint(20) unsigned NOT NULL,
`email` varchar(50) NOT NULL,
`qq` char(15) NOT NULL,
`http` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of contact
-- ----------------------------
INSERT INTO `contact` VALUES ('1', '广东省广州市某某区', '15698933365', '525635555', '225625632688', 'http://baidu.com');
INSERT INTO `contact` VALUES ('2', '广东省广州市海珠区某某地方', '13685964487', '55886611177', '6584758247', 'http://baidu.com');
-- ----------------------------
-- Table structure for goods
-- ----------------------------
DROP TABLE IF EXISTS `goods`;
CREATE TABLE `goods` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`goods_name` char(60) NOT NULL,
`create_time` int(10) unsigned NOT NULL,
`market_price` decimal(10,2) unsigned NOT NULL DEFAULT '0.00',
`shop_price` decimal(10,2) unsigned NOT NULL DEFAULT '0.00',
`brand_id` int(10) unsigned NOT NULL,
`image` char(255) NOT NULL,
`category_id` int(10) unsigned NOT NULL DEFAULT '1',
PRIMARY KEY (`id`),
UNIQUE KEY `id_UNIQUE` (`id`),
KEY `fk_0201_goods_brand1_idx` (`brand_id`),
KEY `fk_0201_goods_category1_idx` (`category_id`),
KEY `image_UNIQUE` (`image`) USING BTREE,
CONSTRAINT `fk_0201_goods_brand1` FOREIGN KEY (`brand_id`) REFERENCES `brand` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT `fk_0201_goods_category1` FOREIGN KEY (`category_id`) REFERENCES `category` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of goods
-- ----------------------------
INSERT INTO `goods` VALUES ('20', 'uuuuu', '1497578144', '29.00', '29.00', '12', 'Public/Upload/2017-06-16/594339d72cd33.jpg', '1');
INSERT INTO `goods` VALUES ('21', 'DIY语音', '1497579150', '55.00', '55.00', '12', 'Public/Upload/2017-06-16/59433e8adea34.jpg', '1');
INSERT INTO `goods` VALUES ('22', '和电话费', '1497578198', '55.00', '55.00', '12', 'Public/Upload/2017-06-16/59433abc37244.jpg', '2');
INSERT INTO `goods` VALUES ('23', '和交付该计划', '1497579054', '1500.00', '1344.00', '9', 'Public/Upload/2017-06-16/59433e2b1ceaf.jpg', '1');
INSERT INTO `goods` VALUES ('24', '鱼仔', '1497579519', '121.00', '121.00', '12', 'Public/Upload/2017-06-16/59433ffc1b11e.jpg', '5');
INSERT INTO `goods` VALUES ('25', '商品商品', '1497578315', '5555.00', '5555.00', '10', 'Public/Upload/2017-06-16/59433b476f053.jpg', '1');
INSERT INTO `goods` VALUES ('27', '555', '1497578335', '444.00', '444.00', '10', 'Public/Upload/2017-06-16/59433b5c72cfa.jpg', '1');
-- ----------------------------
-- Table structure for goods_desc
-- ----------------------------
DROP TABLE IF EXISTS `goods_desc`;
CREATE TABLE `goods_desc` (
`content` text NOT NULL,
`goods_id` int(10) unsigned NOT NULL,
PRIMARY KEY (`goods_id`),
CONSTRAINT `fk_goods_details_0201_goods` FOREIGN KEY (`goods_id`) REFERENCES `goods` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of goods_desc
-- ----------------------------
INSERT INTO `goods_desc` VALUES ('\r\n 衣料手感极好 ', '20');
INSERT INTO `goods_desc` VALUES ('\r\n \r\n \r\n \r\n \r\n \r\n 语音语音 ', '21');
INSERT INTO `goods_desc` VALUES ('\r\n 飞机和环境 ', '22');
INSERT INTO `goods_desc` VALUES ('\r\n \r\n \r\n \r\n \r\n \r\n \r\n 官方活动 ', '23');
INSERT INTO `goods_desc` VALUES ('\r\n \r\n 给力 ', '24');
INSERT INTO `goods_desc` VALUES ('\r\n 555555555555555555555555555555555555 ', '25');
INSERT INTO `goods_desc` VALUES ('\r\n 4444 ', '27');
-- ----------------------------
-- Table structure for goods_img
-- ----------------------------
DROP TABLE IF EXISTS `goods_img`;
CREATE TABLE `goods_img` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`photo` varchar(2000) NOT NULL,
`goods_id` int(10) unsigned NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `id_UNIQUE` (`id`),
KEY `fk_goods_img_0201_goods1_idx` (`goods_id`),
CONSTRAINT `fk_goods_img_0201_goods1` FOREIGN KEY (`goods_id`) REFERENCES `goods` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=72 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of goods_img
-- ----------------------------
INSERT INTO `goods_img` VALUES ('9', 'Public/Upload/2017-06-08/593942e07a840.jpg', '20');
INSERT INTO `goods_img` VALUES ('10', 'Public/Upload/2017-06-08/593942e08cd3d.jpg', '20');
INSERT INTO `goods_img` VALUES ('13', 'Public/Upload/2017-06-08/5939455f76be4.jpg', '22');
INSERT INTO `goods_img` VALUES ('14', 'Public/Upload/2017-06-08/5939455f88cf8.jpg', '22');
INSERT INTO `goods_img` VALUES ('18', 'Public/Upload/2017-06-10/593bcf0e7801c.gif', '25');
INSERT INTO `goods_img` VALUES ('19', 'Public/Upload/2017-06-10/593bcf0e95cb3.gif', '25');
INSERT INTO `goods_img` VALUES ('20', 'Public/Upload/2017-06-10/593bcf0ea8d67.gif', '25');
INSERT INTO `goods_img` VALUES ('22', 'Public/Upload/2017-06-12/593e0e0a2b41a.png', '27');
INSERT INTO `goods_img` VALUES ('31', 'Public/Upload/2017-06-10/593b9c6e528ba.gif', '20');
INSERT INTO `goods_img` VALUES ('32', 'Public/Upload/2017-06-10/593b9c6e528ba.gif', '20');
INSERT INTO `goods_img` VALUES ('33', 'Public/Upload/2017-06-10/593b9c6e528ba.gif', '20');
INSERT INTO `goods_img` VALUES ('34', 'Public/Upload/2017-06-10/593b9c6e528ba.gif', '20');
INSERT INTO `goods_img` VALUES ('37', 'Public/Upload/2017-06-10/593b9c6e528ba.gif', '20');
INSERT INTO `goods_img` VALUES ('38', 'Public/Upload/2017-06-16/59433a9e810cb.jpg', '20');
INSERT INTO `goods_img` VALUES ('39', 'Public/Upload/2017-06-16/59433a9e8d41e.jpg', '20');
INSERT INTO `goods_img` VALUES ('40', 'Public/Upload/2017-06-16/59433a9e9b2c9.jpg', '20');
INSERT INTO `goods_img` VALUES ('41', 'Public/Upload/2017-06-16/59433abc4aeb0.jpg', '22');
INSERT INTO `goods_img` VALUES ('42', 'Public/Upload/2017-06-16/59433ad3de4e9.jpg', '22');
INSERT INTO `goods_img` VALUES ('46', 'Public/Upload/2017-06-16/59433b47605f0.jpg', '25');
INSERT INTO `goods_img` VALUES ('47', 'Public/Upload/2017-06-16/59433b47805af.jpg', '25');
INSERT INTO `goods_img` VALUES ('48', 'Public/Upload/2017-06-16/59433b5c592cc.jpg', '27');
INSERT INTO `goods_img` VALUES ('49', 'Public/Upload/2017-06-16/59433b5c8a400.jpg', '27');
INSERT INTO `goods_img` VALUES ('62', 'Public/Upload/2017-06-16/59433e214509b.jpg', '23');
INSERT INTO `goods_img` VALUES ('69', 'Public/Upload/2017-06-10/593b9c6e528ba.gif', '21');
INSERT INTO `goods_img` VALUES ('70', 'Public/Upload/2017-06-10/593b9c6e528ba.gif', '24');
INSERT INTO `goods_img` VALUES ('71', 'Public/Upload/2017-06-10/593b9c6e528ba.gif', '24');
-- ----------------------------
-- Table structure for goods_spec
-- ----------------------------
DROP TABLE IF EXISTS `goods_spec`;
CREATE TABLE `goods_spec` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`goods_id` int(10) unsigned NOT NULL,
`spec_price` decimal(10,2) unsigned NOT NULL DEFAULT '0.00',
`spec_key` char(30) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=82 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of goods_spec
-- ----------------------------
INSERT INTO `goods_spec` VALUES ('5', '20', '29.00', '2,11');
INSERT INTO `goods_spec` VALUES ('6', '20', '29.00', '2,12');
INSERT INTO `goods_spec` VALUES ('7', '20', '29.00', '11,14');
INSERT INTO `goods_spec` VALUES ('8', '20', '29.00', '12,14');
INSERT INTO `goods_spec` VALUES ('9', '21', '55.00', '2,11');
INSERT INTO `goods_spec` VALUES ('10', '21', '55.00', '2,12');
INSERT INTO `goods_spec` VALUES ('11', '21', '55.00', '11,14');
INSERT INTO `goods_spec` VALUES ('12', '21', '55.00', '12,14');
INSERT INTO `goods_spec` VALUES ('13', '23', '49.00', '2,11');
INSERT INTO `goods_spec` VALUES ('14', '23', '56.00', '2,12');
INSERT INTO `goods_spec` VALUES ('15', '24', '55.00', '2,11');
INSERT INTO `goods_spec` VALUES ('16', '25', '33.00', '2,11');
INSERT INTO `goods_spec` VALUES ('17', '25', '33.00', '2,12');
INSERT INTO `goods_spec` VALUES ('18', '25', '33.00', '2,13');
INSERT INTO `goods_spec` VALUES ('19', '25', '33.00', '11,14');
INSERT INTO `goods_spec` VALUES ('20', '25', '33.00', '12,14');
INSERT INTO `goods_spec` VALUES ('21', '25', '33.00', '13,14');
INSERT INTO `goods_spec` VALUES ('22', '27', '11111.00', '2,11');
INSERT INTO `goods_spec` VALUES ('23', '20', '29.00', '2,11');
INSERT INTO `goods_spec` VALUES ('24', '20', '29.00', '2,12');
INSERT INTO `goods_spec` VALUES ('25', '20', '29.00', '11,14');
INSERT INTO `goods_spec` VALUES ('26', '20', '29.00', '12,14');
INSERT INTO `goods_spec` VALUES ('27', '20', '29.00', '2,11');
INSERT INTO `goods_spec` VALUES ('28', '20', '29.00', '2,12');
INSERT INTO `goods_spec` VALUES ('29', '20', '29.00', '11,14');
INSERT INTO `goods_spec` VALUES ('30', '20', '29.00', '12,14');
INSERT INTO `goods_spec` VALUES ('31', '21', '55.00', '2,11');
INSERT INTO `goods_spec` VALUES ('32', '21', '55.00', '2,12');
INSERT INTO `goods_spec` VALUES ('33', '21', '55.00', '11,14');
INSERT INTO `goods_spec` VALUES ('34', '21', '55.00', '12,14');
INSERT INTO `goods_spec` VALUES ('35', '20', '29.00', '2,11');
INSERT INTO `goods_spec` VALUES ('36', '20', '29.00', '2,12');
INSERT INTO `goods_spec` VALUES ('37', '20', '29.00', '11,14');
INSERT INTO `goods_spec` VALUES ('38', '20', '29.00', '12,14');
INSERT INTO `goods_spec` VALUES ('39', '23', '49.00', '2,11');
INSERT INTO `goods_spec` VALUES ('40', '23', '56.00', '2,12');
INSERT INTO `goods_spec` VALUES ('41', '24', '55.00', '2,11');
INSERT INTO `goods_spec` VALUES ('42', '25', '33.00', '2,11');
INSERT INTO `goods_spec` VALUES ('43', '25', '33.00', '2,12');
INSERT INTO `goods_spec` VALUES ('44', '25', '33.00', '2,13');
INSERT INTO `goods_spec` VALUES ('45', '25', '33.00', '11,14');
INSERT INTO `goods_spec` VALUES ('46', '25', '33.00', '12,14');
INSERT INTO `goods_spec` VALUES ('47', '25', '33.00', '13,14');
INSERT INTO `goods_spec` VALUES ('48', '27', '11111.00', '2,11');
INSERT INTO `goods_spec` VALUES ('49', '21', '55.00', '2,11');
INSERT INTO `goods_spec` VALUES ('50', '21', '55.00', '2,12');
INSERT INTO `goods_spec` VALUES ('51', '21', '55.00', '11,14');
INSERT INTO `goods_spec` VALUES ('52', '21', '55.00', '12,14');
INSERT INTO `goods_spec` VALUES ('53', '23', '49.00', '2,11');
INSERT INTO `goods_spec` VALUES ('54', '23', '56.00', '2,12');
INSERT INTO `goods_spec` VALUES ('55', '23', '49.00', '2,11');
INSERT INTO `goods_spec` VALUES ('56', '23', '56.00', '2,12');
INSERT INTO `goods_spec` VALUES ('57', '23', '49.00', '2,11');
INSERT INTO `goods_spec` VALUES ('58', '23', '56.00', '2,12');
INSERT INTO `goods_spec` VALUES ('59', '23', '49.00', '2,11');
INSERT INTO `goods_spec` VALUES ('60', '23', '56.00', '2,12');
INSERT INTO `goods_spec` VALUES ('61', '23', '49.00', '2,11');
INSERT INTO `goods_spec` VALUES ('62', '23', '56.00', '2,12');
INSERT INTO `goods_spec` VALUES ('63', '23', '49.00', '2,11');
INSERT INTO `goods_spec` VALUES ('64', '23', '56.00', '2,12');
INSERT INTO `goods_spec` VALUES ('65', '21', '55.00', '2,11');
INSERT INTO `goods_spec` VALUES ('66', '21', '55.00', '2,12');
INSERT INTO `goods_spec` VALUES ('67', '21', '55.00', '11,14');
INSERT INTO `goods_spec` VALUES ('68', '21', '55.00', '12,14');
INSERT INTO `goods_spec` VALUES ('69', '21', '55.00', '2,11');
INSERT INTO `goods_spec` VALUES ('70', '21', '55.00', '2,12');
INSERT INTO `goods_spec` VALUES ('71', '21', '55.00', '11,14');
INSERT INTO `goods_spec` VALUES ('72', '21', '55.00', '12,14');
INSERT INTO `goods_spec` VALUES ('73', '21', '55.00', '2,11');
INSERT INTO `goods_spec` VALUES ('74', '21', '55.00', '2,12');
INSERT INTO `goods_spec` VALUES ('75', '21', '55.00', '11,14');
INSERT INTO `goods_spec` VALUES ('76', '21', '55.00', '12,14');
INSERT INTO `goods_spec` VALUES ('77', '21', '55.00', '2,11');
INSERT INTO `goods_spec` VALUES ('78', '21', '55.00', '2,12');
INSERT INTO `goods_spec` VALUES ('79', '21', '55.00', '11,14');
INSERT INTO `goods_spec` VALUES ('80', '21', '55.00', '12,14');
INSERT INTO `goods_spec` VALUES ('81', '24', '55.00', '2,11');
-- ----------------------------
-- Table structure for goods_type
-- ----------------------------
DROP TABLE IF EXISTS `goods_type`;
CREATE TABLE `goods_type` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`type_name` char(10) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of goods_type
-- ----------------------------
INSERT INTO `goods_type` VALUES ('1', 'gdgdgsh');
INSERT INTO `goods_type` VALUES ('2', '手机');
INSERT INTO `goods_type` VALUES ('3', '网络');
-- ----------------------------
-- Table structure for message
-- ----------------------------
DROP TABLE IF EXISTS `message`;
CREATE TABLE `message` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`create_time` int(11) NOT NULL,
`name` varchar(30) NOT NULL,
`content` text NOT NULL,
`phone` bigint(20) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of message
-- ----------------------------
INSERT INTO `message` VALUES ('1', '1497445387', '成功', '成功成功成功成功成功成功成功成功成功成功成功成功成功成功成功成功成功', '13645678945');
-- ----------------------------
-- Table structure for news
-- ----------------------------
DROP TABLE IF EXISTS `news`;
CREATE TABLE `news` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`news_name` varchar(200) NOT NULL,
`create_time` int(10) unsigned NOT NULL,
`content` text NOT NULL,
`image` varchar(200) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of news
-- ----------------------------
INSERT INTO `news` VALUES ('2', '夏季新品即将上市耶耶', '0', '<p>\r\n &lt;p&gt;\r\n &amp;lt;p&amp;gt;\r\n &amp;amp;lt;p&amp;amp;gt;好期待好期待好期待好期待好期待好期待好期待好期待好期待好期待好期待好期待好期待好期待好期待好期待好期待好期待好期待好期待好期待好期待好期待好期待好期待好期待好期待好期待好期待好期待好期待好期待好期待好期待好期待&amp;amp;lt;/p&amp;amp;gt; &amp;lt;/p&amp;gt; &lt;/p&gt; </p>', 'Public/Upload/2017-06-12/593e7933d0786.png');
INSERT INTO `news` VALUES ('4', '比欧体比欧体比欧体比欧体比欧体比欧体比欧体比欧体', '1497528841', '<p>\r\n &lt;p&gt;\r\n &amp;lt;p&amp;gt;\r\n &amp;amp;lt;p&amp;amp;gt;比欧体比欧体比欧体比欧体比欧体比欧比欧体比欧体比欧体比欧体比欧体比欧比欧体比欧体比欧体比欧体比欧体比欧比欧体比欧体比欧体比欧体比欧体比欧比欧体比欧体比欧体比欧体比欧体比欧比欧体比欧体比欧体比欧体比欧体比欧比欧体比欧体比欧体比欧体比欧体比欧比欧体比欧体比欧体比欧体比欧体比欧比欧体比欧体比欧体比欧体比欧体比欧比欧体比欧体比欧体比欧体比欧体比欧&amp;amp;lt;/p&amp;amp;gt; &amp;lt;/p&amp;gt; &lt;/p&gt; </p>', 'Public/Upload/2017-06-15/59427a07d0bd5.png');
-- ----------------------------
-- Table structure for order
-- ----------------------------
DROP TABLE IF EXISTS `order`;
CREATE TABLE `order` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`order_sn` varchar(45) NOT NULL,
`user_id` int(10) unsigned zerofill NOT NULL,
`order_price` decimal(10,2) unsigned zerofill NOT NULL DEFAULT '00000000.00',
`numbel` smallint(5) unsigned zerofill NOT NULL DEFAULT '00000',
`phone` bigint(19) unsigned NOT NULL,
`address` char(45) NOT NULL,
`order_status` tinyint(3) unsigned zerofill NOT NULL DEFAULT '000',
`pay_status` tinyint(3) unsigned zerofill NOT NULL DEFAULT '000',
`shipping_status` tinyint(3) unsigned zerofill NOT NULL DEFAULT '000',
PRIMARY KEY (`id`),
UNIQUE KEY `id_UNIQUE` (`id`),
UNIQUE KEY `order_sn_UNIQUE` (`order_sn`),
UNIQUE KEY `phone_UNIQUE` (`phone`),
KEY `fk_order_user1_idx` (`user_id`),
CONSTRAINT `fk_order_user1` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of order
-- ----------------------------
-- ----------------------------
-- Table structure for order_goods
-- ----------------------------
DROP TABLE IF EXISTS `order_goods`;
CREATE TABLE `order_goods` (
`goods_id` int(10) unsigned NOT NULL,
`order_id` int(10) unsigned zerofill NOT NULL,
`number` smallint(5) unsigned zerofill NOT NULL DEFAULT '00000',
`market_price` decimal(10,2) unsigned zerofill NOT NULL DEFAULT '00000000.00',
`shop_price` decimal(10,2) unsigned zerofill NOT NULL DEFAULT '00000000.00',
PRIMARY KEY (`goods_id`,`order_id`),
KEY `fk_0201_goods_has_order_order1_idx` (`order_id`),
KEY `fk_0201_goods_has_order_0201_goods1_idx` (`goods_id`),
CONSTRAINT `fk_0201_goods_has_order_0201_goods1` FOREIGN KEY (`goods_id`) REFERENCES `goods` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT `fk_0201_goods_has_order_order1` FOREIGN KEY (`order_id`) REFERENCES `order` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of order_goods
-- ----------------------------
-- ----------------------------
-- Table structure for spec
-- ----------------------------
DROP TABLE IF EXISTS `spec`;
CREATE TABLE `spec` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`spec_name` char(20) NOT NULL,
`type_id` int(10) unsigned NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `spec_name` (`spec_name`)
) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of spec
-- ----------------------------
INSERT INTO `spec` VALUES ('13', '内存', '2');
INSERT INTO `spec` VALUES ('14', '100M', '3');
INSERT INTO `spec` VALUES ('15', '像素', '2');
-- ----------------------------
-- Table structure for spec_items
-- ----------------------------
DROP TABLE IF EXISTS `spec_items`;
CREATE TABLE `spec_items` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`items` char(15) NOT NULL,
`spec_id` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of spec_items
-- ----------------------------
INSERT INTO `spec_items` VALUES ('2', '16g', '13');
INSERT INTO `spec_items` VALUES ('6', '4', '14');
INSERT INTO `spec_items` VALUES ('11', '1800w', '15');
INSERT INTO `spec_items` VALUES ('12', '10000w', '15');
INSERT INTO `spec_items` VALUES ('13', '15000w', '15');
INSERT INTO `spec_items` VALUES ('14', 'kdjf', '13');
INSERT INTO `spec_items` VALUES ('15', '6666', '14');
INSERT INTO `spec_items` VALUES ('16', '55', '14');
-- ----------------------------
-- Table structure for user
-- ----------------------------
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`user_name` varchar(18) NOT NULL,
`password` varchar(32) NOT NULL,
`email` varchar(45) NOT NULL,
`qq` bigint(19) unsigned zerofill NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `id_UNIQUE` (`id`),
UNIQUE KEY `user_name_UNIQUE` (`user_name`),
UNIQUE KEY `password_UNIQUE` (`password`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of user
-- ----------------------------
-- ----------------------------
-- Table structure for user_address
-- ----------------------------
DROP TABLE IF EXISTS `user_address`;
CREATE TABLE `user_address` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`phone` bigint(19) unsigned NOT NULL,
`address` varchar(45) NOT NULL,
`name` varchar(25) NOT NULL,
`user_id` int(10) unsigned zerofill NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `id_UNIQUE` (`id`),
UNIQUE KEY `phone_UNIQUE` (`phone`),
UNIQUE KEY `user_addresscol_UNIQUE` (`address`),
KEY `fk_user_address_user1_idx` (`user_id`),
CONSTRAINT `fk_user_address_user1` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of user_address
-- ----------------------------
| true |
c03634eb69b6a4bf8d1e2f8e80d3b422ad6ad3ef | SQL | Tahanima/sqlbolt-solutions | /sql_lesson12_order_of_execution_of_a_query.sql | UTF-8 | 461 | 4.28125 | 4 | [] | no_license | -- Exercise 12 — Tasks
-- 1. Find the number of movies each director has directed
SELECT director,
Count(*) AS number_of_movies
FROM movies
GROUP BY director;
-- 2. Find the total domestic and international sales that can be attributed to each director
SELECT m.director,
Sum (bo.domestic_sales + bo.international_sales) AS total_sales
FROM movies m
INNER JOIN boxoffice bo
ON m.id = bo.movie_id
GROUP BY director;
| true |
50082ef79b5a5f3b5f42f232d3e0e170c7df6df5 | SQL | silence-do-good/stress-test-Postgres-and-MySQL | /dump/low/day20/select1153.sql | UTF-8 | 178 | 2.671875 | 3 | [] | no_license |
SELECT timeStamp, temperature FROM ThermometerOBSERVATION o
WHERE timestamp>'2017-11-19T11:53:00Z' AND timestamp<'2017-11-20T11:53:00Z' AND temperature>=47 AND temperature<=73
| true |
bdd353a9ed30f47b1300ef4abcc0df268edfd3f9 | SQL | ahavanur/yelp-networks | /assets/sql/yelp_schema.sql | UTF-8 | 7,204 | 3.375 | 3 | [] | no_license | SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';
-- -----------------------------------------------------
-- Schema yelp_db
-- -----------------------------------------------------
-- -----------------------------------------------------
-- Schema yelp_db
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `yelp_db` DEFAULT CHARACTER SET utf8 ;
USE `yelp_db` ;
-- -----------------------------------------------------
-- Table `yelp_db`.`business`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `yelp_db`.`business` (
`id` VARCHAR(22) NOT NULL,
`name` VARCHAR(255) NULL,
`neighborhood` VARCHAR(255) NULL,
`address` VARCHAR(255) NULL,
`city` VARCHAR(255) NULL,
`state` VARCHAR(255) NULL,
`postal_code` VARCHAR(255) NULL,
`latitude` FLOAT NULL,
`longitude` FLOAT NULL,
`stars` FLOAT NULL,
`review_count` INT NULL,
`is_open` TINYINT NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `yelp_db`.`hours`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `yelp_db`.`hours` (
`hours` VARCHAR(255) NULL,
`business_id` VARCHAR(22) NOT NULL,
INDEX `fk_hours_business1_idx` (`business_id` ASC),
CONSTRAINT `fk_hours_business1`
FOREIGN KEY (`business_id`)
REFERENCES `yelp_db`.`business` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `yelp_db`.`category`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `yelp_db`.`category` (
`business_id` VARCHAR(22) NOT NULL,
`category` VARCHAR(255) NULL,
INDEX `fk_categories_business1_idx` (`business_id` ASC),
CONSTRAINT `fk_categories_business1`
FOREIGN KEY (`business_id`)
REFERENCES `yelp_db`.`business` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `yelp_db`.`attribute`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `yelp_db`.`attribute` (
`business_id` VARCHAR(22) NOT NULL,
`name` VARCHAR(255) NULL,
`value` TEXT NULL,
INDEX `fk_table1_business_idx` (`business_id` ASC),
CONSTRAINT `fk_table1_business`
FOREIGN KEY (`business_id`)
REFERENCES `yelp_db`.`business` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `yelp_db`.`user`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `yelp_db`.`user` (
`id` VARCHAR(22) NOT NULL,
`name` VARCHAR(255) NULL,
`review_count` INT NULL,
`yelping_since` DATETIME NULL,
`useful` INT NULL,
`funny` INT NULL,
`cool` INT NULL,
`fans` INT NULL,
`average_stars` FLOAT NULL,
`compliment_hot` INT NULL,
`compliment_more` INT NULL,
`compliment_profile` INT NULL,
`compliment_cute` INT NULL,
`compliment_list` INT NULL,
`compliment_note` INT NULL,
`compliment_plain` INT NULL,
`compliment_cool` INT NULL,
`compliment_funny` INT NULL,
`compliment_writer` INT NULL,
`compliment_photos` INT NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `yelp_db`.`review`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `yelp_db`.`review` (
`id` VARCHAR(22) NOT NULL COMMENT ' \n',
`stars` INT NULL,
`date` DATETIME NULL,
`text` TEXT NULL,
`useful` INT NULL,
`funny` INT NULL,
`cool` INT NULL,
`business_id` VARCHAR(22) NOT NULL,
`user_id` VARCHAR(22) NOT NULL COMMENT '\n\n',
PRIMARY KEY (`id`),
INDEX `fk_reviews_business1_idx` (`business_id` ASC),
INDEX `fk_reviews_user1_idx` (`user_id` ASC),
CONSTRAINT `fk_reviews_business1`
FOREIGN KEY (`business_id`)
REFERENCES `yelp_db`.`business` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_reviews_user1`
FOREIGN KEY (`user_id`)
REFERENCES `yelp_db`.`user` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `yelp_db`.`friend`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `yelp_db`.`friend` (
`user_id` VARCHAR(22) NOT NULL,
`friend_id` VARCHAR(22) NULL,
INDEX `fk_friends_user1_idx` (`user_id` ASC),
CONSTRAINT `fk_friends_user1`
FOREIGN KEY (`user_id`)
REFERENCES `yelp_db`.`user` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `yelp_db`.`elite_years`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `yelp_db`.`elite_years` (
`user_id` VARCHAR(22) NOT NULL,
`year` CHAR(4) NULL,
INDEX `fk_elite_years_user1_idx` (`user_id` ASC),
CONSTRAINT `fk_elite_years_user1`
FOREIGN KEY (`user_id`)
REFERENCES `yelp_db`.`user` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `yelp_db`.`checkin`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `yelp_db`.`checkin` (
`business_id` VARCHAR(22) NOT NULL,
`date` VARCHAR(255) NULL,
`count` INT NULL,
INDEX `fk_checkin_business1_idx` (`business_id` ASC),
CONSTRAINT `fk_checkin_business1`
FOREIGN KEY (`business_id`)
REFERENCES `yelp_db`.`business` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `yelp_db`.`tip`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `yelp_db`.`tip` (
`user_id` VARCHAR(22) NOT NULL,
`business_id` VARCHAR(22) NOT NULL,
`text` TEXT NULL,
`date` DATETIME NULL,
`likes` INT NULL,
INDEX `fk_tip_user1_idx` (`user_id` ASC),
INDEX `fk_tip_business1_idx` (`business_id` ASC),
CONSTRAINT `fk_tip_user1`
FOREIGN KEY (`user_id`)
REFERENCES `yelp_db`.`user` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_tip_business1`
FOREIGN KEY (`business_id`)
REFERENCES `yelp_db`.`business` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `yelp_db`.`photo`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `yelp_db`.`photo` (
`id` VARCHAR(22) NOT NULL,
`business_id` VARCHAR(22) NOT NULL,
`caption` VARCHAR(255) NULL,
`label` VARCHAR(255) NULL,
PRIMARY KEY (`id`),
INDEX `fk_photo_business1_idx` (`business_id` ASC),
CONSTRAINT `fk_photo_business1`
FOREIGN KEY (`business_id`)
REFERENCES `yelp_db`.`business` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
| true |
09d3a793aee3c010d86a2ad257a34ea9e85d9d73 | SQL | cuissto59/ServiceCar | /db/servicecar.sql | UTF-8 | 14,507 | 3.28125 | 3 | [] | no_license | Drop DATABASE IF EXISTS `servicecar`;
CREATE DATABASE IF NOT EXISTS `servicecar`/*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci */ /*!80016 DEFAULT ENCRYPTION='N' */;
USE `servicecar`;
-- MySQL dump 10.13 Distrib 8.0.22, for Win64 (x86_64)
--
-- Host: 127.0.0.1 Database: servicecar
-- ------------------------------------------------------
-- Server version 8.0.22
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!50503 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `conductor`
--
DROP TABLE IF EXISTS `conductor`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `conductor` (
`user` int NOT NULL,
`cin` varchar(20) NOT NULL,
`telephone_number` int NOT NULL,
`adress` varchar(100) NOT NULL,
`active` bit(1) NOT NULL,
PRIMARY KEY (`user`) USING BTREE,
CONSTRAINT `conductor_ibfk_1` FOREIGN KEY (`user`) REFERENCES `user` (`id_user`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `conductor`
--
LOCK TABLES `conductor` WRITE;
/*!40000 ALTER TABLE `conductor` DISABLE KEYS */;
INSERT INTO `conductor` VALUES (2,'AE2039343',615553583,'Kenitra',_binary ''),(5,'AB12620',661394430,'salé',_binary '');
/*!40000 ALTER TABLE `conductor` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `user`
--
DROP TABLE IF EXISTS `user`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `user` (
`id_user` int NOT NULL AUTO_INCREMENT,
`f_name` varchar(20) NOT NULL,
`l_name` varchar(20) NOT NULL,
`login` varchar(64) NOT NULL,
`password` varchar(64) NOT NULL,
`is_admin` bit(1) NOT NULL,
PRIMARY KEY (`id_user`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `user`
--
LOCK TABLES `user` WRITE;
/*!40000 ALTER TABLE `user` DISABLE KEYS */;
INSERT INTO `user` VALUES (1,'Ahmed','mahmoud','admin','admin',_binary ''),(2,'Ahmed','mahmoud','conductor2','conductor2',_binary '\0'),(3,'Ahmed','mahmoud','ahmedken111@gmail.co','password',_binary '\0'),(5,'taha','lahrizi','conductor1','conductor1',_binary '\0');
/*!40000 ALTER TABLE `user` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `vehicle`
--
DROP TABLE IF EXISTS `vehicle`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `vehicle` (
`id_vehicle` int NOT NULL AUTO_INCREMENT,
`vehicle_conductor` int NOT NULL,
`img` varchar(100) NOT NULL,
`description` text NOT NULL,
`in_use` bit(1) NOT NULL,
PRIMARY KEY (`id_vehicle`),
KEY `vehicle_conductor` (`vehicle_conductor`),
CONSTRAINT `vehicle_ibfk_1` FOREIGN KEY (`vehicle_conductor`) REFERENCES `conductor` (`user`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `vehicle`
--
LOCK TABLES `vehicle` WRITE;
/*!40000 ALTER TABLE `vehicle` DISABLE KEYS */;
INSERT INTO `vehicle` VALUES (2,5,'test.jpg','Yaris city',_binary ''),(4,2,'7.png','suzuki',_binary '\0'),(6,2,'trest.jpg','Dacia sandero',_binary '');
/*!40000 ALTER TABLE `vehicle` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `vehicle_accident`
--
DROP TABLE IF EXISTS `vehicle_accident`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `vehicle_accident` (
`id_vehicle_ac` int NOT NULL,
`type` varchar(50) NOT NULL,
`damage_description` text NOT NULL,
`was_insured` bit(1) DEFAULT NULL,
`date` datetime NOT NULL,
PRIMARY KEY (`id_vehicle_ac`) USING BTREE,
CONSTRAINT `vehicle_accident_ibfk_1` FOREIGN KEY (`id_vehicle_ac`) REFERENCES `vehicle` (`id_vehicle`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `vehicle_accident`
--
LOCK TABLES `vehicle_accident` WRITE;
/*!40000 ALTER TABLE `vehicle_accident` DISABLE KEYS */;
INSERT INTO `vehicle_accident` VALUES (2,'moyenne','parchoc et led far endomagees',_binary '\0','2021-06-25 05:54:29'),(4,'grave','chasis et moteurs detruit',_binary '','2011-09-15 03:14:39');
/*!40000 ALTER TABLE `vehicle_accident` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `vehicle_breakdown`
--
DROP TABLE IF EXISTS `vehicle_breakdown`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `vehicle_breakdown` (
`id_breakdown` int NOT NULL AUTO_INCREMENT,
`id_vehicle_bd` int NOT NULL,
`problem` varchar(50) NOT NULL,
`description` text NOT NULL,
PRIMARY KEY (`id_breakdown`),
KEY `id_vehicle_bd` (`id_vehicle_bd`),
CONSTRAINT `vehicle_breakdown_ibfk_1` FOREIGN KEY (`id_vehicle_bd`) REFERENCES `vehicle` (`id_vehicle`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `vehicle_breakdown`
--
LOCK TABLES `vehicle_breakdown` WRITE;
/*!40000 ALTER TABLE `vehicle_breakdown` DISABLE KEYS */;
INSERT INTO `vehicle_breakdown` VALUES (1,4,'signal de contact en panne','le signal a ete endommager'),(2,2,'probleme de vidange','depassement du cota du vidange');
/*!40000 ALTER TABLE `vehicle_breakdown` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `vehicle_buy_contract`
--
DROP TABLE IF EXISTS `vehicle_buy_contract`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `vehicle_buy_contract` (
`id_vehicle_bc` int NOT NULL,
`provider` varchar(30) DEFAULT NULL,
`buy_date` date DEFAULT NULL,
`contract_number` varchar(50) DEFAULT NULL,
`warranty_years` int DEFAULT NULL,
`amount` decimal(10,2) DEFAULT NULL,
`tva` decimal(10,2) DEFAULT NULL,
PRIMARY KEY (`id_vehicle_bc`) USING BTREE,
CONSTRAINT `vehicle_buy_contract_ibfk_1` FOREIGN KEY (`id_vehicle_bc`) REFERENCES `vehicle` (`id_vehicle`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `vehicle_buy_contract`
--
LOCK TABLES `vehicle_buy_contract` WRITE;
/*!40000 ALTER TABLE `vehicle_buy_contract` DISABLE KEYS */;
INSERT INTO `vehicle_buy_contract` VALUES (2,'toyota house','2014-06-09','145',5,120000.00,2.00),(4,'3rd party seller','2010-06-04','14597',2,200000.00,0.40),(6,'reanult-dacia maison','2007-09-20','2367',5,145200.00,2.00);
/*!40000 ALTER TABLE `vehicle_buy_contract` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `vehicle_fuel`
--
DROP TABLE IF EXISTS `vehicle_fuel`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `vehicle_fuel` (
`id_sp_fu` int NOT NULL,
`quantity` decimal(10,2) NOT NULL,
PRIMARY KEY (`id_sp_fu`) USING BTREE,
CONSTRAINT `vehicle_fuel_ibfk_1` FOREIGN KEY (`id_sp_fu`) REFERENCES `vehicle_spending` (`id_sp`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `vehicle_fuel`
--
LOCK TABLES `vehicle_fuel` WRITE;
/*!40000 ALTER TABLE `vehicle_fuel` DISABLE KEYS */;
INSERT INTO `vehicle_fuel` VALUES (1,15.00);
/*!40000 ALTER TABLE `vehicle_fuel` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `vehicle_general_info`
--
DROP TABLE IF EXISTS `vehicle_general_info`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `vehicle_general_info` (
`id_vehicle_gi` int NOT NULL,
`matricul_number` varchar(30) NOT NULL,
`code` varchar(20) NOT NULL,
`grey_card` varchar(20) NOT NULL,
`chassis_number` varchar(20) NOT NULL,
`vehicle_type` enum('Voiture','Camion') NOT NULL,
`acquisition` enum('ACHAT') NOT NULL,
`mark` varchar(20) NOT NULL,
`model` varchar(20) NOT NULL,
`model_year` int NOT NULL,
`in_use_yr` int NOT NULL,
`km` int NOT NULL,
`body_type` varchar(30) NOT NULL,
`fuel_type` enum('DIESEL','ESSENCE','HYBRIDE','ELECTRIQUE') NOT NULL,
PRIMARY KEY (`id_vehicle_gi`) USING BTREE,
CONSTRAINT `vehicle_general_info_ibfk_1` FOREIGN KEY (`id_vehicle_gi`) REFERENCES `vehicle` (`id_vehicle`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `vehicle_general_info`
--
LOCK TABLES `vehicle_general_info` WRITE;
/*!40000 ALTER TABLE `vehicle_general_info` DISABLE KEYS */;
INSERT INTO `vehicle_general_info` VALUES (2,'17458-أ-2','123','11111','148799','Voiture','ACHAT','toyota','yaris ',2014,2015,123000,'chasis','DIESEL'),(4,'15697-أ-59','111','78945','1220','Camion','ACHAT','suzuki','pick up',2011,2017,1456000,'chasis','DIESEL');
/*!40000 ALTER TABLE `vehicle_general_info` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `vehicle_maintenance_plan`
--
DROP TABLE IF EXISTS `vehicle_maintenance_plan`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `vehicle_maintenance_plan` (
`id_vehicle_mp` int NOT NULL,
`description` text NOT NULL,
PRIMARY KEY (`id_vehicle_mp`) USING BTREE,
CONSTRAINT `vehicle_maintenance_plan_ibfk_1` FOREIGN KEY (`id_vehicle_mp`) REFERENCES `vehicle` (`id_vehicle`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `vehicle_maintenance_plan`
--
LOCK TABLES `vehicle_maintenance_plan` WRITE;
/*!40000 ALTER TABLE `vehicle_maintenance_plan` DISABLE KEYS */;
INSERT INTO `vehicle_maintenance_plan` VALUES (2,'lorem ipsum'),(4,'cogito decarte');
/*!40000 ALTER TABLE `vehicle_maintenance_plan` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `vehicle_reparation`
--
DROP TABLE IF EXISTS `vehicle_reparation`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `vehicle_reparation` (
`id_vehicle_re` int NOT NULL,
`amount` decimal(10,2) NOT NULL,
`date` datetime NOT NULL,
PRIMARY KEY (`id_vehicle_re`) USING BTREE,
CONSTRAINT `vehicle_reparation_ibfk_1` FOREIGN KEY (`id_vehicle_re`) REFERENCES `vehicle` (`id_vehicle`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `vehicle_reparation`
--
LOCK TABLES `vehicle_reparation` WRITE;
/*!40000 ALTER TABLE `vehicle_reparation` DISABLE KEYS */;
INSERT INTO `vehicle_reparation` VALUES (2,2000.00,'2021-06-23 12:36:37');
/*!40000 ALTER TABLE `vehicle_reparation` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `vehicle_services`
--
DROP TABLE IF EXISTS `vehicle_services`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `vehicle_services` (
`id_vehicle_se` int NOT NULL,
`type` varchar(20) NOT NULL,
`km` int NOT NULL,
`amount` decimal(10,2) NOT NULL,
`start_date` datetime NOT NULL,
`end_date` datetime NOT NULL,
PRIMARY KEY (`id_vehicle_se`) USING BTREE,
CONSTRAINT `vehicle_services_ibfk_1` FOREIGN KEY (`id_vehicle_se`) REFERENCES `vehicle` (`id_vehicle`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `vehicle_services`
--
LOCK TABLES `vehicle_services` WRITE;
/*!40000 ALTER TABLE `vehicle_services` DISABLE KEYS */;
INSERT INTO `vehicle_services` VALUES (2,'vacant',120000,1405.00,'2021-06-23 12:31:06','2021-06-23 12:31:10'),(4,'vacant',14022,1470.00,'2021-06-23 12:31:48','2021-06-23 12:31:54');
/*!40000 ALTER TABLE `vehicle_services` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `vehicle_spending`
--
DROP TABLE IF EXISTS `vehicle_spending`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `vehicle_spending` (
`id_sp` int NOT NULL AUTO_INCREMENT,
`id_vehicle_sp` int NOT NULL,
`id_conductor_sp` int NOT NULL,
`date_sp` date NOT NULL,
`time_sp` time NOT NULL,
`type` varchar(20) NOT NULL,
`amount` decimal(10,2) NOT NULL,
PRIMARY KEY (`id_sp`) USING BTREE,
KEY `id_vehicle_sp` (`id_vehicle_sp`),
KEY `id_conductor_sp` (`id_conductor_sp`),
CONSTRAINT `vehicle_spending_ibfk_1` FOREIGN KEY (`id_vehicle_sp`) REFERENCES `vehicle` (`id_vehicle`),
CONSTRAINT `vehicle_spending_ibfk_2` FOREIGN KEY (`id_conductor_sp`) REFERENCES `conductor` (`user`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `vehicle_spending`
--
LOCK TABLES `vehicle_spending` WRITE;
/*!40000 ALTER TABLE `vehicle_spending` DISABLE KEYS */;
INSERT INTO `vehicle_spending` VALUES (1,2,5,'2021-06-02','02:00:00','vacant',200.00),(2,4,2,'2020-04-02','01:00:00','vacant',450.00);
/*!40000 ALTER TABLE `vehicle_spending` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2021-06-24 19:15:14
| true |
4b043f309927da6cde0a65a398a7d6f7693228c4 | SQL | CrazyIvanftw/EDAF20_Database | /KrustyKookies/sql_folder/Krusty_Kookies_DB_Init.sql | UTF-8 | 9,564 | 3.109375 | 3 | [] | no_license | -- Delete the tables if they exist. To be able to drop
-- them in arbitrary order, disable foreign key checks.
-- Turn of key checks
set foreign_key_checks = 0;
-- Drop tables in arbitrary order
drop table if exists Cookies;
drop table if exists Ingredients;
drop table if exists Recipes;
drop table if exists IngredientDelivery;
drop table if exists Customers;
drop table if exists Orders;
drop table if exists Pallets;
drop table if exists NbrPallets;
drop table if exists LoadingOrders;
drop table if exists LoadingBills;
drop table if exists Tests;
drop table if exists LabQueue;
-- Turn on key checks
set foreign_key_checks = 1;
create TABLE Cookies(
cookieName varchar(30),
PRIMARY KEY(cookieName)
);
create TABLE Ingredients(
ingredient varchar(40),
amount decimal(6,2) NOT NULL,
PRIMARY KEY(ingredient)
);
create TABLE Recipes(
cookieName varchar(30),
ingredient varchar(40),
ingredientAmount decimal(6,2) NOT NULL,
PRIMARY KEY(cookieName, ingredient),
FOREIGN KEY(cookieName) REFERENCES Cookies(cookieName),
FOREIGN KEY(ingredient) REFERENCES Ingredients(ingredient)
);
create TABLE IngredientDelivery(
ingredient varchar(40),
deliveryTimeStamp datetime NOT NULL,
deliveryAmount decimal(6,2) NOT NULL,
PRIMARY KEY(ingredient, deliveryTimeStamp),
FOREIGN KEY(ingredient) REFERENCES Ingredients(ingredient)
);
create TABLE Customers(
customerName varchar(20),
customerAdress varchar(50) NOT NULL,
PRIMARY KEY(customerName)
);
-- We should delete the deliveryTimeStamp because we really don't need it in two places...
create TABLE Orders(
orderNbr int auto_increment,
expectedDate DATE,
nbrPalletsTotal int,
customerName varchar(20),
PRIMARY KEY(orderNbr),
FOREIGN KEY(customerName) REFERENCES Customers(customerName)
);
create TABLE Pallets(
palletNbr int auto_increment,
productionTimeStamp datetime NOT NULL,
cookieName varchar(30) NOT NULL,
orderNbr int,
loaded boolean,
blocked boolean,
PRIMARY KEY(palletNbr),
FOREIGN KEY(cookieName) REFERENCES Cookies(cookieName),
FOREIGN KEY(orderNbr) REFERENCES Orders(orderNbr)
);
create TABLE NbrPallets(
orderNbr int NOT NULL,
cookieName varchar(30) NOT NULL,
nbrPallets int NOT NULL,
FOREIGN KEY(orderNbr) REFERENCES Orders(orderNbr),
FOREIGN KEY(cookieName) REFERENCES Cookies(cookieName)
);
create TABLE LoadingOrders(
loadNbr int auto_increment,
orderNbr int,
PRIMARY KEY(loadNbr, orderNbr),
FOREIGN KEY(orderNbr) REFERENCES Orders(orderNbr)
);
create TABLE LoadingBills(
loadNbr int,
orderNbr int,
deliveryTimeStamp datetime,
PRIMARY KEY(loadNbr, orderNbr),
FOREIGN KEY(orderNbr) REFERENCES Orders(orderNbr)
);
-- Initial Data
INSERT into Cookies values('Nut cookie');
INSERT into Cookies values('Amneris');
INSERT into Cookies values('Tango');
INSERT into Cookies values('Almond delight');
INSERT into Cookies values('Berliner');
INSERT into Cookies values('Nut ring');
INSERT into Ingredients values('Flour', 0);
INSERT into Ingredients values('Butter', 0);
INSERT into Ingredients values('Icing sugar', 0);
INSERT into Ingredients values('Roasted, chopped nuts', 0);
INSERT into Ingredients values('Fine-ground nuts', 0);
INSERT into Ingredients values('Ground, roasted nuts', 0);
INSERT into Ingredients values('Sugar', 0);
INSERT into Ingredients values('Eggs', 0);
INSERT into Ingredients values('Egg whites', 0);
INSERT into Ingredients values('Bread crumbs', 0);
INSERT into Ingredients values('Chocolate', 0);
INSERT into Ingredients values('Marzipan', 0);
INSERT into Ingredients values('Potato Starch', 0);
INSERT into Ingredients values('Wheat flour', 0);
INSERT into Ingredients values('Sodium bicarbonate', 0);
INSERT into Ingredients values('Vanilla', 0);
INSERT into Ingredients values('Chopped almonds', 0);
INSERT into Ingredients values('Cinnamon', 0);
INSERT into Ingredients values('Vanilla sugar', 0);
INSERT into Recipes values('Nut Ring','Flour', 450);
INSERT into Recipes values('Nut Ring','Butter', 450);
INSERT into Recipes values('Nut Ring','Icing Sugar', 190);
INSERT into Recipes values('Nut Ring','Roasted, chopped nuts', 225);
INSERT into Recipes values('Nut Cookie','Fine-ground nuts', 750);
INSERT into Recipes values('Nut Cookie','Ground, roasted nuts', 625);
INSERT into Recipes values('Nut Cookie','Bread crumbs', 125);
INSERT into Recipes values('Nut Cookie','Sugar', 375);
INSERT into Recipes values('Nut Cookie','Egg whites', 3.5);
INSERT into Recipes values('Nut Cookie','Chocolate', 50);
INSERT into Recipes values('Amneris','Marzipan', 750);
INSERT into Recipes values('Amneris','Butter', 250);
INSERT into Recipes values('Amneris','Eggs', 250);
INSERT into Recipes values('Amneris','Potato Starch', 25);
INSERT into Recipes values('Amneris','Wheat flour', 25);
INSERT into Recipes values('Tango','Butter', 200);
INSERT into Recipes values('Tango','Sugar', 250);
INSERT into Recipes values('Tango','Flour', 300);
INSERT into Recipes values('Tango','Sodium bicarbonate', 4);
INSERT into Recipes values('Tango','Vanilla', 2);
INSERT into Recipes values('Almond delight','Butter', 400);
INSERT into Recipes values('Almond delight','Sugar', 270);
INSERT into Recipes values('Almond delight','Chopped almonds', 279);
INSERT into Recipes values('Almond delight','Flour', 400);
INSERT into Recipes values('Almond delight','Cinnamon', 10);
INSERT into Recipes values('Berliner','Flour', 350);
INSERT into Recipes values('Berliner','Butter', 250);
INSERT into Recipes values('Berliner','Icing Sugar', 100);
INSERT into Recipes values('Berliner','Eggs', 50);
INSERT into Recipes values('Berliner','Vanilla sugar', 5);
INSERT into Recipes values('Berliner','Chocolate', 50);
INSERT into Customers values('Kaffebrod AB', 'Landskrona');
INSERT into Customers values('Bjudkakor AB', 'Ystad');
INSERT into Customers values('Kalaskakor AB', 'Kristianstad');
INSERT into Customers values('Gastkakor AB', 'Hassleholm');
INSERT into Customers values('Skanekakor AB', 'Perstorp');
INSERT into Customers values('Finkakor AB', 'Helsingborg');
INSERT into Customers values('Smabrod AB', 'Malmo');
-- PROCEDURES
DROP PROCEDURE IF EXISTS delivery;
DROP PROCEDURE IF EXISTS producePallet;
DROP PROCEDURE IF EXISTS placeOrder;
DROP PROCEDURE IF EXISTS orderDelivered;
DROP PROCEDURE IF EXISTS palletIntoAnOrder;
DROP PROCEDURE IF EXISTS palletOutOfAnOrder;
DROP PROCEDURE IF EXISTS orderIntoALoad;
-- Put ingredient amounts into ingredient stock
DELIMITER //
CREATE PROCEDURE delivery(
IN ing varchar(40),
IN dt datetime,
IN am decimal(6,2)
)
BEGIN
insert into ingredientdelivery values(ing, dt, am);
update ingredients set amount = amount + am where ingredient = ing;
END//
DELIMITER ;
-- Make a Pallet
DELIMITER //
CREATE PROCEDURE producePallet(
IN cName varchar(30),
IN dt datetime
)
BEGIN
update Ingredients set amount = amount - (
select ingredientAmount
from Recipes
where Ingredients.ingredient = Recipes.ingredient AND cookieName = cName
)
where ingredient in (
select ingredient
from Recipes
where cookieName = cName
);
insert into pallets values(null, dt, cName, null, 0, 0);
END//
DELIMITER ;
-- Make an Order
DELIMITER //
CREATE PROCEDURE placeOrder(
IN custName varchar(20),
IN expDate date,
IN almondDelight int(11),
IN amneris int(11),
IN berliner int(11),
IN nutCookie int(11),
IN nutRing int(11),
IN tango int(11)
)
BEGIN
insert into orders values(null, expDate, null, custName);
set @ordNbr = (
select max(orderNbr)
from orders
);
insert into nbrPallets values(@ordNbr, 'Almond delight', almondDelight);
insert into nbrPallets values(@ordNbr, 'Amneris', amneris);
insert into nbrPallets values(@ordNbr, 'Berliner', berliner);
insert into nbrPallets values(@ordNbr, 'Nut cookie', nutCookie);
insert into nbrPallets values(@ordNbr, 'Nut ring', nutRing);
insert into nbrPallets values(@ordNbr, 'Tango', tango);
update orders set nbrPalletsTotal = (
select sum(nbrPallets)
from nbrPallets
where orderNbr = @ordNbr
)
where orderNbr = @ordNbr;
END//
DELIMITER ;
-- Mark an Order as Delivered
DELIMITER //
CREATE PROCEDURE orderDelivered(
IN oNbr int,
IN dTimeStamp DateTime
)
BEGIN
insert into loadingBills (loadNbr, orderNbr, deliveryTimeStamp) select loadNbr, orderNbr, dTimeStamp from loadingOrders where orderNbr = oNbr;
delete from loadingOrders where orderNbr = oNbr;
END//
DELIMITER ;
-- Assign a pallet to an Order
DELIMITER //
CREATE PROCEDURE palletIntoAnOrder(
IN pNbr int,
IN oNbr int
)
BEGIN
update pallets set orderNbr = oNbr where palletNbr = pNbr;
-- update orders set nbrPalletsTotal = nbrPalletsTotal-1 where orderNbr = oNbr;
END//
DELIMITER ;
-- Unassign a Pallet from an Order
-- Bug: could screw up things if pallet unassigned
DELIMITER //
CREATE PROCEDURE palletOutOfAnOrder(
IN pNbr int
)
BEGIN
-- set @oNbr = (select orderNbr from pallets where palletNbr = pNbr);
update pallets set orderNbr = null where palletNbr = pNbr;
-- update orders set nbrPalletsTotal = nbrPalletsTotal+1 where orderNbr = @oNbr;
END//
DELIMITER ;
-- Assign an Order into a Load
DELIMITER //
CREATE PROCEDURE orderIntoALoad(
IN lNbr int,
IN oNbr int
)
BEGIN
insert into loadingorders values(lNbr , oNbr);
update pallets set loaded = 1 where orderNbr = oNbr;
END//
DELIMITER ;
| true |
5edf1aa778e47efbe349e71fc240431d6af70a8e | SQL | klimsava/students | /db/students_db.sql | UTF-8 | 3,434 | 3.46875 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 4.9.3
-- https://www.phpmyadmin.net/
--
-- Host: localhost:8889
-- Generation Time: Nov 23, 2020 at 09:06 PM
-- Server version: 5.7.26
-- PHP Version: 7.4.1
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `students_db`
--
-- --------------------------------------------------------
--
-- Table structure for table `courses`
--
CREATE TABLE `courses` (
`id` int(11) NOT NULL,
`name` varchar(255) NOT NULL,
`description` varchar(255) NOT NULL,
`time` time DEFAULT '12:00:00'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `courses`
--
INSERT INTO `courses` (`id`, `name`, `description`, `time`) VALUES
(2, 'PHP', 'Training in the programming language PHP', '11:35:00'),
(4, 'Java Script', 'Training in the programming language JS.', '12:30:00'),
(5, 'MySQL', 'Learning and working with the database MySQL', '14:45:00');
-- --------------------------------------------------------
--
-- Table structure for table `students`
--
CREATE TABLE `students` (
`id` int(11) NOT NULL,
`first_name` varchar(255) NOT NULL,
`last_name` varchar(255) NOT NULL,
`age` int(11) NOT NULL DEFAULT '18'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `students`
--
INSERT INTO `students` (`id`, `first_name`, `last_name`, `age`) VALUES
(11, 'Klim', 'Savamovich', 24),
(12, 'Max', 'Owner', 13),
(13, 'adam', 'Smith', 50),
(20, 'test', 'test', 5);
-- --------------------------------------------------------
--
-- Table structure for table `student_courses`
--
CREATE TABLE `student_courses` (
`student_id` int(11) DEFAULT NULL,
`course_id` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `student_courses`
--
INSERT INTO `student_courses` (`student_id`, `course_id`) VALUES
(13, 5),
(12, 5),
(12, 4);
--
-- Indexes for dumped tables
--
--
-- Indexes for table `courses`
--
ALTER TABLE `courses`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `name` (`name`);
--
-- Indexes for table `students`
--
ALTER TABLE `students`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `first_name` (`first_name`),
ADD UNIQUE KEY `last_name` (`last_name`);
--
-- Indexes for table `student_courses`
--
ALTER TABLE `student_courses`
ADD KEY `stud_ind` (`student_id`),
ADD KEY `cour_ind` (`course_id`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `courses`
--
ALTER TABLE `courses`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
--
-- AUTO_INCREMENT for table `students`
--
ALTER TABLE `students`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=21;
--
-- Constraints for dumped tables
--
--
-- Constraints for table `student_courses`
--
ALTER TABLE `student_courses`
ADD CONSTRAINT `student_courses_ibfk_1` FOREIGN KEY (`student_id`) REFERENCES `students` (`id`) ON DELETE CASCADE,
ADD CONSTRAINT `student_courses_ibfk_2` FOREIGN KEY (`course_id`) REFERENCES `courses` (`id`) ON DELETE CASCADE;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
| true |
22c8ecb8ee66208e7b5e5758ded4f0f4eb718ff8 | SQL | laurisuurvali/training-app | /src/test/resources/db/data.sql | UTF-8 | 1,417 | 2.984375 | 3 | [] | no_license | INSERT INTO ROLE (status, name)
VALUES ('ACTIVE', 'ROLE_USER'),
('ACTIVE', 'ROLE_ADMIN');
INSERT INTO APP_USER (status, first_name, last_name, username, password)
VALUES ('ACTIVE', 'Stanislav', 'Ratsinski', 's.ra@hotmail.com', '$2a$04$AM7ufAiabz8axmplAVXUI.95FpvD1o33zQMJmBKEkFkFr/Y/VbBHK'),
('ACTIVE', 'Leonard', 'Ratsinski', 'leo@hotmail.com', '$2a$04$AM7ufAiabz8axmplAVXUI.95FpvD1o33zQMJmBKEkFkFr/Y/VbBHK'),
('ACTIVE', 'Margarita', 'Leonova', 'ma.l@hotmail.com', '$2a$04$AM7ufAiabz8axmplAVXUI.95FpvD1o33zQMJmBKEkFkFr/Y/VbBHK');
INSERT INTO SUBSCRIPTION (start_date)
VALUES (TO_DATE('17/12/2015', 'DD/MM/YYYY')),
(TO_DATE('17/02/2018', 'DD/MM/YYYY'));
INSERT INTO CHALLENGE (challenge_name, week_quantity)
VALUES ('Initial Super Challenge', 8),
('Second Amazing Challenge', 9);
INSERT INTO USER_ROLE (USER_ID, ROLE_ID)
VALUES (1, 1),
(1, 2),
(2, 1),
(3, 1);
INSERT INTO MEAL (MEAL_NAME, CALORIES)
VALUES ('Soup', 200);
UPDATE SUBSCRIPTION SET challenge_challenge_id = 1 WHERE subscription_id = 1;
UPDATE SUBSCRIPTION SET challenge_challenge_id = 2 WHERE subscription_id = 2;
UPDATE APP_USER SET subscription_id = 1 WHERE user_id = 2;
UPDATE APP_USER SET subscription_id = 2 WHERE user_id = 3; | true |
a6d90154d39946eb76e698c4bcd5ab08a569f620 | SQL | octonion/cricket | /ipl/sos/test_random.sql | UTF-8 | 245 | 3.078125 | 3 | [] | no_license | select npl.parameter,npl.type,npl.level,nbf.estimate
from ipl._parameter_levels npl
left outer join ipl._basic_factors nbf
on (nbf.factor,nbf.level,nbf.type)=(npl.parameter,npl.level,npl.type)
where npl.type='random'
order by parameter,level;
| true |
591562b3a0a3f062e70a09a1dedef4d3746014d2 | SQL | grooves/engineer_training | /KIRAryo1/sql_drill/Pra_update_subquery_e2.sql | UTF-8 | 409 | 3.828125 | 4 | [] | no_license | UPDATE
Salary AS k
SET
k.Amount = k.Amount + (
SELECT
SUM(u.Quantity * p.Price) * 0.03
FROM
Sales AS u
JOIN
Products AS p
ON p.ProductID = u.productID
WHERE
k.EmployeeID = u.EmployeeID
GROUP BY
u.EmployeeID
)
WHERE
PayDate = '2007-08-25'
AND
EXISTS
(
SELECT
'X'
FROM
Sales
WHERE
Sales.EmployeeID = k.EmployeeID
AND
Sales.SaleDate < '2007-08-25'
)
;
| true |
efc0a06282292218b36bdd7d74ee6ce8d0819064 | SQL | puritanlife/ApplyNow | /ApplyNow/TaskHosting/Stored Procedures/CancelJob.sql | UTF-8 | 299 | 2.984375 | 3 | [] | no_license |
-- Cancel Job SP
CREATE PROCEDURE [TaskHosting].[CancelJob]
@JobId uniqueidentifier
AS
BEGIN
IF @JobId IS NULL
BEGIN
RAISERROR('@JobId argument is wrong.', 16, 1)
RETURN
END
SET NOCOUNT ON
UPDATE TaskHosting.Job SET IsCancelled = 1 WHERE JobId = @JobId
END | true |
2282d50a1e5564e2d670e15e45bad6b0d46bfc4a | SQL | Woodu/sg_f | /fox_sv/socialsv/.svn/pristine/22/2282d50a1e5564e2d670e15e45bad6b0d46bfc4a.svn-base | UTF-8 | 313 | 3.171875 | 3 | [] | no_license | -- フレンドコード
DROP TABLE IF EXISTS friend_code_data;
CREATE TABLE friend_code_data (
friend_code INTEGER AUTO_INCREMENT PRIMARY KEY, -- フレンドコード
user_id INTEGER NOT NULL, -- ユーザーID
create_ts TIMESTAMP NULL DEFAULT NULL, -- 作成時間
INDEX (user_id)
);
| true |
3a8841d2a26cea4a2ec4476ab16786657e4817d3 | SQL | fazrinhafiz97/lecturer-student-database | /lecturer/register.sql | UTF-8 | 1,888 | 2.921875 | 3 | [
"MIT"
] | permissive | -- phpMyAdmin SQL Dump
-- version 5.0.2
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Jul 02, 2020 at 12:02 PM
-- Server version: 10.4.11-MariaDB
-- PHP Version: 7.2.30
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `project`
--
-- --------------------------------------------------------
--
-- Table structure for table `register`
--
CREATE TABLE `register` (
`courses` text NOT NULL,
`subject` text NOT NULL,
`subject_code` varchar(25) NOT NULL,
`section` int(10) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `register`
--
INSERT INTO `register` (`courses`, `subject`, `subject_code`, `section`) VALUES
('Information Security', 'Web Security', 'BIS21340', 0),
('Information Security', 'Web Security', 'BIS21340', 0),
('Information Security', 'Web Security', 'BIS21340', 0),
('Information Security', 'Web Security', 'BIS21340', 0),
('Information Security', 'Web Security', 'BIS21340', 0),
('Information Security', 'Web Security', 'BIS21340', 3),
('Information Security', 'Web Security', 'BIS21340', 3),
('Information Security', 'Database', 'BIS21340', 2),
('Information Security', 'Database', 'BIS21340', 2),
('Information Security', 'Database', 'BIS21340', 2),
('Information Security', 'Database', 'BIS21340', 2),
('Information Security', 'Database', 'BIS21340', 2),
('Information Security', 'Database', 'BIS21340', 2);
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
| true |
63b15dbb54629a94a738b810584105902e322180 | SQL | aidaerfanian/itemsonsale | /target/classes/db/migration/V0004__orders.sql | UTF-8 | 770 | 3.203125 | 3 | [] | no_license | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
* Author: aida.erfanian
* Created: Nov. 13, 2020
*/
CREATE TABLE `orders` (
`order_id` int NOT NULL auto_increment,
`timestamp` timestamp NOT NULL default current_timestamp ON UPDATE current_timestamp,
`item_id` int NOT NULL,
`user_id` int NOT NULL,
`user_ranking` int,
`status` varchar(255),
`favorite` tinyint(1) NOT NULL default 0,
FOREIGN KEY (`item_id`)
REFERENCES items(item_id)
ON DELETE CASCADE,
FOREIGN KEY (`user_id`)
REFERENCES users(user_id)
ON DELETE CASCADE,
PRIMARY KEY (`order_id`)
); | true |
f06fac15e33b30159352465f3f51234bd69fbafa | SQL | rtilersmith/DNDCombatTracker | /db/addToList.sql | UTF-8 | 242 | 2.6875 | 3 | [] | no_license | INSERT INTO COMBATANTS (Character_ID, Current_HP, Current_Init, room)
VALUES (${Character_ID}, ${health}, ${init}, ${room});
SELECT * FROM CombatantInfo ci
LEFT JOIN Combatants c
ON ci.ID = c.Character_ID
where C.Character_ID=${Character_ID}; | true |
c6275d523e854a1e1fddb013b767da16dd98a098 | SQL | fedspendingtransparency/data-act-broker-backend | /dataactvalidator/config/sqlrules/c27_award_financial.sql | UTF-8 | 3,846 | 3.890625 | 4 | [
"CC0-1.0"
] | permissive | -- The File C GrossOutlayAmountByAward_CPE balance for a TAS, DEFC, program activity code + name, object class code,
-- direct/reimbursable flag, and Award ID combination should continue to be reported in subsequent periods during the
-- FY, once it has been submitted to DATA Act, unless the most recently reported outlay balance for this award breakdown
-- was zero. This only applies to File C outlays, not TOA.
WITH c27_prev_sub_{0} AS
(SELECT CASE WHEN sub.is_quarter_format
THEN sub_q.submission_id
ELSE sub_p.submission_id
END AS "submission_id"
FROM submission AS sub
LEFT JOIN submission AS sub_p
ON sub_p.reporting_fiscal_year = sub.reporting_fiscal_year
AND sub_p.reporting_fiscal_period = sub.reporting_fiscal_period - 1
AND COALESCE(sub_p.cgac_code, sub_p.frec_code) = COALESCE(sub.cgac_code, sub.frec_code)
AND sub_p.publish_status_id != 1
AND sub_p.is_fabs IS FALSE
LEFT JOIN submission AS sub_q
ON sub_q.reporting_fiscal_year = sub.reporting_fiscal_year
AND sub_q.reporting_fiscal_period = sub.reporting_fiscal_period - 3
AND COALESCE(sub_q.cgac_code, sub_q.frec_code) = COALESCE(sub.cgac_code, sub.frec_code)
AND sub_q.publish_status_id != 1
AND sub_q.is_fabs IS FALSE
WHERE sub.is_fabs IS FALSE
AND sub.submission_id = {0}),
c27_prev_outlays_{0} AS (
SELECT tas,
disaster_emergency_fund_code,
program_activity_code,
program_activity_name,
object_class,
by_direct_reimbursable_fun,
fain,
uri,
piid,
parent_award_id,
gross_outlay_amount_by_awa_cpe
FROM published_award_financial AS paf
JOIN c27_prev_sub_{0} AS sub
ON sub.submission_id = paf.submission_id
WHERE COALESCE(gross_outlay_amount_by_awa_cpe, 0) <> 0)
SELECT
NULL AS "row_number",
po.tas,
po.disaster_emergency_fund_code,
po.program_activity_code,
po.program_activity_name,
po.object_class,
po.by_direct_reimbursable_fun,
po.fain,
po.uri,
po.piid,
po.parent_award_id,
po.gross_outlay_amount_by_awa_cpe,
po.tas AS "uniqueid_TAS",
po.disaster_emergency_fund_code AS "uniqueid_DisasterEmergencyFundCode",
po.program_activity_code AS "uniqueid_ProgramActivityCode",
po.program_activity_name AS "uniqueid_ProgramActivityName",
po.object_class AS "uniqueid_ObjectClass",
po.by_direct_reimbursable_fun AS "uniqueid_ByDirectReimbursableFundingSource",
po.fain AS "uniqueid_FAIN",
po.uri AS "uniqueid_URI",
po.piid AS "uniqueid_PIID",
po.parent_award_id AS "uniqueid_ParentAwardId"
FROM c27_prev_outlays_{0} AS po
WHERE NOT EXISTS (
SELECT 1
FROM award_financial AS af
WHERE UPPER(COALESCE(po.fain, '')) = UPPER(COALESCE(af.fain, ''))
AND UPPER(COALESCE(po.uri, '')) = UPPER(COALESCE(af.uri, ''))
AND UPPER(COALESCE(po.piid, '')) = UPPER(COALESCE(af.piid, ''))
AND UPPER(COALESCE(po.parent_award_id, '')) = UPPER(COALESCE(af.parent_award_id, ''))
AND UPPER(COALESCE(po.tas, '')) = UPPER(COALESCE(af.tas, ''))
AND (UPPER(COALESCE(po.disaster_emergency_fund_code, '')) = UPPER(COALESCE(af.disaster_emergency_fund_code, ''))
OR UPPER(COALESCE(po.disaster_emergency_fund_code, '')) = '9')
AND UPPER(COALESCE(po.object_class, '')) = UPPER(COALESCE(af.object_class, ''))
AND UPPER(COALESCE(po.program_activity_name, '')) = UPPER(COALESCE(af.program_activity_name, ''))
AND UPPER(COALESCE(po.object_class, '')) = UPPER(COALESCE(af.object_class, ''))
AND UPPER(COALESCE(po.by_direct_reimbursable_fun, '')) = UPPER(COALESCE(af.by_direct_reimbursable_fun, ''))
AND af.submission_id = {0}
AND af.gross_outlay_amount_by_awa_cpe IS NOT NULL
);
| true |
1282a30bd1fd4f9f38abc3aa6ce71d22dc619605 | SQL | Aubin13/alx-higher_level_programming-1 | /0x0D-SQL_introduction/11-best_score.sql | UTF-8 | 166 | 2.953125 | 3 | [] | no_license | -- Script that lists all records with a score >= 10 in the second_table of hbtn_0c_0
SELECT score, name
FROM second_table
WHERE score >= 10
ORDER BY score DESC;
| true |
efbac9c2bccd977f02687fe6e8b8e63e1ef2ccff | SQL | hmailserver/hmailserver | /hmailserver/tools/Scripts/DeliveryLog/DeliveryLog.MSSQL.sql | UTF-8 | 664 | 2.90625 | 3 | [] | no_license | create table hm_deliverylog
(
deliveryid int identity (1, 1) not null ,
deliveryfrom varchar(255) not null,
deliveryfilename varchar(255) not null,
deliverytime datetime not null,
deliverysubject nvarchar(255) not null,
deliverybody ntext not null
)
ALTER TABLE hm_deliverylog ADD CONSTRAINT hm_deliverylog_pk PRIMARY KEY NONCLUSTERED (deliveryid)
create table hm_deliverylog_recipients
(
deliveryrecipientid int identity (1, 1) not null,
deliveryid int not null,
deliveryrecipientaddress varchar(255) not null
)
ALTER TABLE hm_deliverylog_recipients ADD CONSTRAINT hm_deliverylog_recipients_pk PRIMARY KEY NONCLUSTERED (deliveryrecipientid)
| true |
b8547361ca9433da3c2e70fd78b62ee78b527f8a | SQL | marcohern/daily.marcohern.com | /sql/tables/daily.sql | UTF-8 | 826 | 3.296875 | 3 | [] | no_license | DROP TABLE IF EXISTS daily;
CREATE TABLE daily(
id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
day DATE NOT NULL,
processed ENUM('true','false') NOT NULL DEFAULT 'false',
transport NUMERIC(20,2) NOT NULL,
food NUMERIC(20,2) NOT NULL,
purchases NUMERIC(20,2) NOT NULL,
sortie NUMERIC(20,2) NOT NULL,
others NUMERIC(20,2) NOT NULL,
db_transport NUMERIC(20,2) NOT NULL,
db_food NUMERIC(20,2) NOT NULL,
db_purchases NUMERIC(20,2) NOT NULL,
db_sortie NUMERIC(20,2) NOT NULL,
db_others NUMERIC(20,2) NOT NULL,
cash NUMERIC(20,2) NOT NULL,
debit NUMERIC(20,2) NOT NULL,
input NUMERIC(20,2) NOT NULL,
balance NUMERIC(20,2) NOT NULL,
output NUMERIC(20,2) NOT NULL,
created DATETIME NOT NULL DEFAULT '2000-01-01 00:00:00',
updated DATETIME NULL,
INDEX ix_daily_day (day DESC)
);
| true |
990e29cf0d5a0da5c57f979f7994c11fff6788fe | SQL | figofosandy/repobaru | /week3/day5/materisql.sql | UTF-8 | 2,551 | 3.890625 | 4 | [] | no_license | -- create keyword
-- buat database
create database coba;
show databases;
-- buat table
use coba;
create table cobaTable(cobaColumn int(3));
show tables;
-- alter keyword
-- nambah column baru
use coba;
alter table cobaTable add columnBaru int(5);
desc cobaTable;
-- ngubah column
use coba;
alter table cobaTable modify columnBaru varchar(30);
desc cobaTable;
-- hapus column
use coba;
alter table cobaTable drop column columnBaru;
desc cobaTable;
-- truncate keyword
-- isi data table
use coba;
alter table cobaTable add (columnBaru int(5) auto_increment, primary key(columnBaru));
insert into cobaTable(cobaColumn) values (3),(5);
select * from cobaTable;
-- reset table;
use coba;
truncate table cobaTable;
desc cobaTable;
select * from cobaTable;
-- isi data table lagi;
use coba;
insert into cobaTable(cobaColumn) values (10),(11);
select * from cobaTable;
-- drop keyword
-- hapus table
use coba;
drop table cobaTable;
show tables;
-- hapus database
drop database coba;
show databases;
-- SQL Syntax
-- Where Clause
select * from belajarsql.user; -- contoh table
select * from belajarsql.user where nama='Ramis';
-- In Clause
select * from belajarsql.user; -- contoh table
select * from belajarsql.user where nama in ('Ramis','Ana');
-- Not In Clause
select * from belajarsql.user; -- contoh table
select * from belajarsql.user where nama not in ('Ramis','Ana');
-- Between Clause
select * from belajarsql.user; -- contoh table
select * from belajarsql.user where user_id between 1 and 3;
-- Like Clause
select * from belajarsql.user; -- contoh table
select * from belajarsql.user where nama like 'R%'; -- % wildcard untuk semua
select * from belajarsql.user where nama like '__a%'; -- _ wildcard untuk 1 karakter
-- SQL Join
-- Inner Join
select * from day3.provinsi;
select * from day3.kota;
select * from day3.provinsi join day3.kota on day3.provinsi.idProvinsi=day3.kota.idProvinsi;
-- Outer Join
-- Left Join
select * from day3.provinsi;
select * from day3.kota;
select * from day3.provinsi left join day3.kota on day3.provinsi.idProvinsi=day3.kota.idProvinsi;
-- Right Join
use day3;
select * from provinsi;
select * from kota;
select * from provinsi right join kota on provinsi.idProvinsi=kota.idProvinsi;
| true |
e1b941cf3509ada09ddddc6967f8d1ea363a8044 | SQL | VICRODRIMA/CaseTecnico | /SQL/exec1.sql | UTF-8 | 323 | 3.375 | 3 | [] | no_license | /*
Com base no modelo acima, escreva um comando SQL que liste a quantidade de registros por
Status com sua descrição.
*/
SELECT COUNT(1) AS ContadorDeRegistros, b.dsStatus AS Descricao
FROM tb_Processo a
INNER JOIN tb_Status b on a.idStatus = b.idStatus
GROUP BY b.dsStatus
ORDER BY ContadorDeRegistros DESC | true |
21a4fd08a3ffa12e024c7e43527d09520dda704d | SQL | OVazquezVillegas/Complex-knowledge-repository | /Data/SQL/SQL course/sql-crash-course-master/Labs/01 Lab One - SQL Queries/First_query.sql | UTF-8 | 1,496 | 4.53125 | 5 | [
"MIT"
] | permissive |
--1)How many files are in the inventory
SELECT COUNT (*) AS file_count
FROM film
--2)What does a sample input of the film look like?
SELECT *
FROM film
LIMIT 100
-- 3) What files are longer than three hours? Order by title
--reverse alphabetic order
SELECT title, release_year, rental_duration, rating
FROM film
WHERE length >= 180
ORDER BY title DESC
--4) What films are longer than 3 hours and have a rental
--duration of a week order by rating
SELECT title, length/60.0 AS length_in_hours, release_year,
rental_duration, rating
FROM film
WHERE length >= 180
AND rental_duration = 7
ORDER BY rating
--5)What are the max and min rental rates of the
--movies in inventory
SELECT MAX(rental_rate) AS max_rate, MIN(rental_rate) AS min_rate
FROM film
--6) What is the average rental rate
SELECT AVG (rental_rate)
FROM film
--7) Find the range of dates in the payment table
SELECT MIN(payment_date), MAX(payment_date)
FROM payment
--8) What customers made a payment in May? Order by date
SELECT c.customer_id, c.first_name, c.last_name, p.payment_date
FROM customer c
JOIN payment p
ON c.customer_id = p.customer_id
WHERE payment_date >= '20070401'
ORDER BY p.payment_date
--9) What is the average payment by customer? Display results
--by ascending amount.
SELECT c.customer_id, c.first_name, c.last_name,
AVG (p.amount) AS average_payment
FROM customer c
JOIN payment p
ON c.customer_id = p.customer_id
GROUP BY c.customer_id, c.first_name, c.last_name
ORDER BY AVG(p.amount) DESC
| true |
db70f33b2dcf9b66ca2108ecced583f384838dda | SQL | chboschiero/mpjp | /mySql/s11.sql | UTF-8 | 362 | 3.546875 | 4 | [] | no_license | -- check null
select first_name, last_name
from employees
where commission_pct is not null;
-- null in operations
select first_name, last_name, 12 * salary * commission_pct
from employees;
-- what if null
select first_name, last_name, 12 * salary * ifnull(commission_pct, 0) -- se è null mette commission_pct a 0 (che moltiplicato da sempre 0)
from employees; | true |
5562f0109c4be8be0d81d18a3dc234cf01794eb7 | SQL | chrissienoodle/Gestionnaire-de-Clefs | /out/artifacts/web_war_exploded/WEB-INF/classes/dao/dbcreation.sql | UTF-8 | 5,506 | 3.046875 | 3 | [] | no_license | -- Reconstruction de la base de données
DROP DATABASE IF EXISTS gesttrousseau;
CREATE DATABASE gesttrousseau;
USE gesttrousseau;
-- tables
CREATE TABLE fonctions
(
code int(4) PRIMARY KEY AUTO_INCREMENT,
libelle varchar(255) NOT NULL
) ENGINE = INNODB;
INSERT INTO fonctions (libelle) VALUE ('Developpeur');
INSERT INTO fonctions (libelle) VALUE ('Agent d''entretien');
INSERT INTO fonctions (libelle) VALUE ('Chef de projet');
INSERT INTO fonctions (libelle) VALUE ('Plombier');
INSERT INTO fonctions (libelle) VALUE ('Formateur');
CREATE TABLE entreprises (
code int(4) PRIMARY KEY AUTO_INCREMENT,
nom varchar(80) NOT NULL,
adresse varchar(255) NOT NULL
) ENGINE = INNODB;
INSERT INTO entreprises (nom, adresse) VALUES ('Afpa', '366 Avenue Georges Durand, 72100 Le Mans');
INSERT INTO entreprises (nom, adresse) VALUES ('ENI ecole informatique', '2B Rue Benjamin Franklin, ZAC Moulin Neuf, Rue Benjamin Franklin, 44800 Saint-Herblain');
INSERT INTO entreprises (nom, adresse) VALUES ('Netflix', '100 Winchester Circle, Los Gatos, CA 95032');
INSERT INTO entreprises (nom, adresse) VALUES ('Amazon', '410 Terry Ave. North Seattle, WA 98109-5210');
INSERT INTO entreprises (nom, adresse) VALUES ('Oracle', '500 Oracle Parkway, Redwood Shores, CA 94065');
INSERT INTO entreprises (nom, adresse) VALUES ('Google', '8 Rue de Londres-15-15 Bis Rue de Clichy 75009 Paris France');
CREATE TABLE personnes (
id int(5) PRIMARY KEY AUTO_INCREMENT,
prenom varchar(80) NOT NULL,
nom varchar(80) NOT NULL,
email varchar(200) NOT NULL,
code_entreprise int(4) NOT NULL,
code_fonction int(4) NOT NULL
) ENGINE = INNODB;
INSERT INTO personnes (prenom, nom, email, code_entreprise, code_fonction) VALUES ('Alexandre', 'Besnier', 'alex.besnier@lol.fr', 1, 2);
INSERT INTO personnes (prenom, nom, email, code_entreprise, code_fonction) VALUES ('Vincent', 'Dobremel', 'vdobremel@salut.fr', 4, 1);
INSERT INTO personnes (prenom, nom, email, code_entreprise, code_fonction) VALUES ('Laurence', 'Bodzen', 'lolo@lol.fr', 6, 2);
INSERT INTO personnes (prenom, nom, email, code_entreprise, code_fonction) VALUES ('Cindy', 'Derrien', 'cindyderrien@merci.pt', 2, 5);
INSERT INTO personnes (prenom, nom, email, code_entreprise, code_fonction) VALUES ('Florent', 'Houdayer', 'houd.the.dude@gmail.com', 3, 3);
INSERT INTO personnes (prenom, nom, email, code_entreprise, code_fonction) VALUES ('Christophe', 'Boulay', 'chrisllym@qstein.yay', 4, 4);
INSERT INTO personnes (prenom, nom, email, code_entreprise, code_fonction) VALUES ('Christine', 'Gunsenheimer', 'noodle@ninja.com', 2, 5);
INSERT INTO personnes (prenom, nom, email, code_entreprise, code_fonction) VALUES ('David', 'Conte', 'david@conte.fr', 3, 5);
INSERT INTO personnes (prenom, nom, email, code_entreprise, code_fonction) VALUES ('Ludovic', 'Poussin', 'ludo@poussin.couic', 4, 5);
INSERT INTO personnes (prenom, nom, email, code_entreprise, code_fonction) VALUES ('Dan Alexandre', 'Versabeau', 'versabeauda@hotmail.fr', 4, 5);
CREATE TABLE users (
id int(5) PRIMARY KEY,
login varchar(255) NOT NULL,
password varchar(255) NOT NULL,
date_crea timestamp DEFAULT CURRENT_TIMESTAMP,
conn_nb int(5) DEFAULT 0,
is_suppr boolean DEFAULT false
) ENGINE = INNODB;
INSERT INTO users (id, login, password) VALUES (1,'alex', 'besnier');
INSERT INTO users (id, login, password) VALUES (2,'vincent', 'dobremel');
INSERT INTO users (id, login, password) VALUES (3,'laurence', 'bodzen');
INSERT INTO users (id, login, password) VALUES (6,'christophe', 'boulay');
INSERT INTO users (id, login, password) VALUES (7,'noodle', 'root');
INSERT INTO users (id, login, password) VALUES (8,'david', 'conte');
CREATE TABLE clefs (
id int(5) PRIMARY KEY AUTO_INCREMENT,
porte varchar(255) NOT NULL,
reference varchar(255) NOT NULL,
id_personne int(5) DEFAULT null,
is_dispo boolean DEFAULT true
) ENGINE = INNODB;
INSERT INTO clefs (porte, reference, id_personne, is_dispo) VALUES ('3B', '15 rue des chapelles', 1, false);
INSERT INTO clefs (porte, reference, id_personne, is_dispo) VALUES ('multipla', 'multipla rehaussee', 8, false);
INSERT INTO clefs (porte, reference, id_personne, is_dispo) VALUES ('or', 'assure longue vie, bonheur et prosperite', null, true);
INSERT INTO clefs (porte, reference, id_personne, is_dispo) VALUES ('55', 'rfa4645r', 3, false);
INSERT INTO clefs (porte, reference, id_personne, is_dispo) VALUES ('78', 'dfgdf89g9', null, true);
INSERT INTO clefs (porte, reference, id_personne, is_dispo) VALUES ('89', 'dgffg84', 4, false);
INSERT INTO clefs (porte, reference, id_personne, is_dispo) VALUES ('9', 'dfgdf95', 6, false);
INSERT INTO clefs (porte, reference, id_personne, is_dispo) VALUES ('2Bis', 'd98ze7r', 5, false);
INSERT INTO clefs (porte, reference, id_personne, is_dispo) VALUES ('63', 'id1fg15', 7, false);
-- foreign key
ALTER TABLE clefs
ADD CONSTRAINT fk_clef_personne FOREIGN KEY (id_personne) REFERENCES personnes(id);
ALTER TABLE personnes
ADD CONSTRAINT fk_personne_entreprise FOREIGN KEY (code_entreprise) REFERENCES entreprises(code);
ALTER TABLE personnes
ADD CONSTRAINT fk_personne_fonction FOREIGN KEY (code_fonction) REFERENCES fonctions(code);
ALTER TABLE users
ADD CONSTRAINT fk_user_personne FOREIGN KEY (id) REFERENCES personnes(id);
| true |
c4ebc54d93d3554f289f1200ba0a810955d21fbc | SQL | RonLandagan/RamenDataAnalysis | /RamenPortfolio.sql | UTF-8 | 2,117 | 4.3125 | 4 | [] | no_license | -- Sanity Check
SELECT *
FROM RamenRatings
ORDER BY Stars DESC
-- Find how many 5 star reviews belong to each country of origin
SELECT Country, COUNT(1) AS NumberOf5Stars
FROM RamenRatings
WHERE Stars=5
GROUP BY Country
ORDER BY NumberOf5Stars desc
-- Find which brand produces the most ramen varieties
SELECT Brand, COUNT(1) AS NumberOfRamenVarieties
FROM RamenRatings
GROUP BY Brand
ORDER BY NumberOfRamenVarieties desc
-- Find a relationship between Style and Stars
WITH StyleCTE(Style, AverageRating, NumberOfReviews)
AS
(
SELECT Style, AVG(Stars) AS AverageRating, COUNT(1) AS NumberOfReviews
FROM RamenRatings
WHERE Stars is not null
GROUP BY Style
)
SELECT Style, AverageRating
FROM StyleCTE
Where NumberOfReviews > 50
ORDER BY AverageRating desc
-- Which countries are found in the Top Ten and how many times
SELECT Country, COUNT(1) AS NumberOfTopTens
FROM RamenRatings
Where [Top Ten] is not null
GROUP BY Country
ORDER BY NumberOfTopTens desc
-- Which brands are found in the Top Tens and how many times
SELECT Brand, COUNT(1) AS NumberOfTopTens
FROM RamenRatings
Where [Top Ten] is not null
GROUP BY Brand
ORDER BY NumberOfTopTens desc
-- Creating views to store data for later visualizations
CREATE VIEW FiveStarCountries as
SELECT Country, COUNT(1) AS NumberOf5Stars
FROM RamenRatings
WHERE Stars=5
GROUP BY Country
CREATE VIEW BrandVarieties as
SELECT Brand, COUNT(1) AS NumberOfRamenVarieties
FROM RamenRatings
GROUP BY Brand
CREATE VIEW StylesVsStars as
WITH StyleCTE(Style, AverageRating, NumberOfReviews)
AS
(
SELECT Style, AVG(Stars) AS AverageRating, COUNT(1) AS NumberOfReviews
FROM RamenRatings
WHERE Stars is not null
GROUP BY Style
)
SELECT Style, AverageRating
FROM StyleCTE
Where NumberOfReviews > 50
CREATE VIEW CountriesBelongingToTopTen as
SELECT Country, COUNT(1) AS NumberOfTopTens
FROM RamenRatings
Where [Top Ten] is not null
GROUP BY Country
CREATE VIEW BrandsBelongingToTopTen as
SELECT Brand, COUNT(1) AS NumberOfTopTens
FROM RamenRatings
Where [Top Ten] is not null
GROUP BY Brand
| true |
b15a75daa33be7067396b9844b719b93b618a4ed | SQL | chokvn/SQL---Hackerrank | /Aggregation/Weather Observation Station 02.sql | UTF-8 | 160 | 2.8125 | 3 | [] | no_license | /*
Challenge reference:
https://www.hackerrank.com/challenges/weather-observation-station-2
*/
SELECT ROUND(SUM(LAT_N), 2), ROUND(SUM(LONG_W),2) FROM station;
| true |
799e11c8c00573c415755e014d7c9321f091145d | SQL | MLQX/my_simple_blog | /create_table.sql | UTF-8 | 232 | 2.59375 | 3 | [] | no_license | drop table if exists entries;
create table entries(
[id] integer primary key autoincrement,
[title] string not null unique,
[content] TEXT not null,
[createtime] TimeStamp NOT NULL DEFAULT (datetime('now','localtime'))
);
| true |
6ce0bd4de2e703fa16480d6eee8d99723b29b88c | SQL | xiaofenduier/hardware | /hardware/src/main/resources/sql/probe.sql | UTF-8 | 934 | 2.78125 | 3 | [] | no_license | /*
Navicat Premium Data Transfer
Source Server : localhost
Source Server Type : MySQL
Source Server Version : 80012
Source Host : localhost
Source Database : hardware
Target Server Type : MySQL
Target Server Version : 80012
File Encoding : utf-8
Date: 09/27/2019 18:11:55 PM
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for `probe`
-- ----------------------------
DROP TABLE IF EXISTS `probe`;
CREATE TABLE `probe` (
`id` int(3) NOT NULL AUTO_INCREMENT,
`probe_mac` varchar(20) DEFAULT NULL,
`status` int(1) DEFAULT NULL,
`location` varchar(20) DEFAULT NULL,
`is_normal` int(1) DEFAULT NULL,
`regular_throughput` int(10) DEFAULT NULL,
`on_line` int(1) DEFAULT NULL,
`version` varchar(10) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8;
SET FOREIGN_KEY_CHECKS = 1;
| true |
35ef1cbdd91e8adf17a3112567b14aeb4a3893dc | SQL | MORourke3/DataSytemsLabs | /Lab 6.sql | UTF-8 | 1,597 | 4.25 | 4 | [] | no_license | -- 1 --
select distinct customers.name, customers.city
from customers
where city in (
select city
from (
(select products.city, count(products.city)
from products
group by products.city
order by count DESC
limit 1))
as X)
-- 2 --
select products.name
from products
where priceUSD < (
select avg(priceUSD)
from products)
order by products.name ASC
-- 3 --
select customers.name, orders.pid, orders.dollars
from customers join orders
on orders.cid = customers.cid
order by dollars DESC
-- 4 --
select customers.name, coalesce(sum(orders.qty), 0)
from orders inner join products
on orders.pid = products.pid
full outer join customers
on customers.cid = orders.cid
group by customers.cid
order by customers.name DESC
-- 5 --
select customers.name, products.name, agents.name
from customers join orders
on customers.cid = orders.cid
join agents
on orders.aid = agents.aid
join products
on products.pid = orders.pid
where orders.aid in (
select aid
from agents
where city = 'Tokyo')
-- 6 --
select orders.ordno, orders.qty * products.priceUSD * (1 - customers.discount/100) as "check", orders.dollars as "dollars"
from orders, products, customers
where (orders.pid = products.pid)
and (orders.cid = customers.cid)
and ((orders.qty * products.priceUSD * (1 - customers.discount/100)) != orders.dollars)
-- 7 --
A left outer join displays all of the rows from the "left" table and if they have anythign that matches on the right table.
A right outer join displays all of the rows of the "right" table and if they have anyhing that matches on the left table.
| true |
fdf06ee5e8a41725bb98cd1b4f8864dd09e88a89 | SQL | youngarifswag6690/vapezone-tubes-native | /db_vape.sql | UTF-8 | 4,754 | 2.796875 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 4.8.4
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Jan 01, 2019 at 02:51 PM
-- Server version: 10.1.37-MariaDB
-- PHP Version: 7.0.33
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `db_vape`
--
-- --------------------------------------------------------
--
-- Table structure for table `admin`
--
CREATE TABLE `admin` (
`username` varchar(20) NOT NULL,
`password` varchar(20) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `admin`
--
INSERT INTO `admin` (`username`, `password`) VALUES
('admin', 'uhuy');
-- --------------------------------------------------------
--
-- Table structure for table `category`
--
CREATE TABLE `category` (
`id_category` int(100) NOT NULL,
`category` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `product`
--
CREATE TABLE `product` (
`id_product` int(20) NOT NULL,
`product_name` varchar(150) NOT NULL,
`description` text NOT NULL,
`category` varchar(100) NOT NULL,
`price` varchar(20) NOT NULL,
`image` varchar(150) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `product`
--
INSERT INTO `product` (`id_product`, `product_name`, `description`, `category`, `price`, `image`) VALUES
(1, 'VGOD ELITE AUTHENTIC MECHANICAL MOD hggh m', '<p>Specifications : VGOD Elite Crest Design Deep Set VGOD Engraving Diameter: 24mm Height: 85mm 510 Hybrid Connection Floating Battery Adjustment Aerospace Carbon Fiber Switch Plastic Tube Insert for Battery Protection Isi di dalam box : 1pcs Vgod Elite Series Mechanical Mod 1 pcs Vgod Bag 2 pcs Vgod Sticker 1 pcs Spring / Per Cadangan 1 Manual Book</p>', 'Mechanical Mod', 'Rp.1.000.000', 'vgodmod.jpg'),
(2, 'BANASPATI COMPETITION MOD MECHA - BY ULTIMA TIMESVAPE AUTHENT', '<p>anaspati Mecha Mod Authentic by Ultimavape Mechanical Mod Juara di Invex, firing josh banget bisa pakai batre 18650 atau 21700 - full copper material - silver plated pin - hybrid system - Battery Compability: 18650/20700/21700 - springless, magnetless - ultem push button. mech mod karya anak bangsa bahan copper push button bawah ultem (heat preventing) pin silver plated support baterai 18650/20700/21700</p>', 'Mechanical Mod', 'Rp.1.300.000', '152779112968614_d2ea4cf5-7786-4aab-be0e-e784859adb9f.png'),
(3, 'HEX OHM V3 BY CRAVING VAPOR (AUTHENTIC) VAPEZOO ', '<p>Product Description Min Volts: 3 Volts Max Volts: 6 Volts Max Amps: 30 Amps Max Watts: 180 Watts Enclosure: Anodized Aluminum Battery Sled: Ultem Power Circuit: HEX-T/30-c Resistance Range: .10 Recommended Ohms: .2</p>', 'Mod ', 'Rp.4.000.000', 'HexOhm_V3_Box_Mod_180W_Hex_Angels_Powdercoat__BLACK_AUTHENTI.jpg');
-- --------------------------------------------------------
--
-- Table structure for table `profile`
--
CREATE TABLE `profile` (
`id_toko` int(50) NOT NULL,
`nama_toko` varchar(100) NOT NULL,
`address` text NOT NULL,
`contact` varchar(255) NOT NULL,
`image` varchar(255) NOT NULL,
`description` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `profile`
--
INSERT INTO `profile` (`id_toko`, `nama_toko`, `address`, `contact`, `image`, `description`) VALUES
(1, 'Vape Zone', 'Jl. Raya lohbener lama No.08', 'vapezone@gmail.com', 'vp1sfb.png', 'Kami menyediakan berbagai keperluan vaping seperti Mod, Atomizer, Cotton, Coil, battre, liquid, dll');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `category`
--
ALTER TABLE `category`
ADD PRIMARY KEY (`id_category`);
--
-- Indexes for table `product`
--
ALTER TABLE `product`
ADD PRIMARY KEY (`id_product`);
--
-- Indexes for table `profile`
--
ALTER TABLE `profile`
ADD PRIMARY KEY (`id_toko`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `category`
--
ALTER TABLE `category`
MODIFY `id_category` int(100) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `product`
--
ALTER TABLE `product`
MODIFY `id_product` int(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
--
-- AUTO_INCREMENT for table `profile`
--
ALTER TABLE `profile`
MODIFY `id_toko` int(50) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
| true |
34efe77499bd11da5ce142552798bcadc3fbad04 | SQL | daizhongde/authority | /src/person/daizhongde/authority/config/AuthorityUrrelation.sql | UTF-8 | 2,756 | 2.75 | 3 | [] | no_license | /** Effective config begin there **/
--@JavaScript var AuthorityUrrelation = {};
--@JavaScript AuthorityUrrelation.query = {};
--@JavaScript AuthorityUrrelation.Add = {};
--@JavaScript AuthorityUrrelation.Update = {};
--@JavaScript AuthorityUrrelation.read = {};
--@JavaScript AuthorityUrrelation.Del = {};
--@JavaScript AuthorityUrrelation.Combobox = {};
--@JavaScript AuthorityUrrelation.Nest = {};
--@JavaScript AuthorityUrrelation.Export = {};
--@JavaScript AuthorityUrrelation.Query.query.SQL
select t1.N_UID "n_uid",
t1.N_RID "n_rid",
t1.C_CTIME "c_ctime",
t1.C_CIP "c_cip",
t1.C_CREATOR "c_creator"
from tool.t_authority_urrelation t1
/* tableData HQL */
--@JavaScript AuthorityUrrelation.Query.query.HQL
--@JavaScript AuthorityUrrelation.Query.query.JPQL
-- AuthorityUrrelation.Read.read.SQL,Criteria.ALIAS_TO_ENTITY_MAP will convert column name to UpperCase,column alias must different avoid map key cover
--@JavaScript AuthorityUrrelation.Read.read.SQL
select t1.N_UID "n_uid",
t1.N_RID "n_rid",
t1.C_CTIME "c_ctime",
t1.C_CIP "c_cip",
t1.C_CREATOR "c_creator"
from tool.t_authority_urrelation t1
-- AuthorityUrrelation.Read.read.HQL, hql haven't decode function, also '||' can't explain in hql
--@JavaScript AuthorityUrrelation.Read.read.HQL
-- AuthorityUrrelation.Read.read.hql=select new map(t1.NMid as id, t1.CMname as name, decode(t1.CMleaf, 'true', '\u662F', 'false', '\u5426', t1.CMleaf) as leaf,t1.NMorder as order1,p.CMname as name2, t1.CMpath as path, t1.CMnote as note ) from TAuthorityUrrelation t1 left outer join t1.NMparent p
--@JavaScript AuthorityUrrelation.Read.read.JPQL
-- SQL for select AuthorityUrrelation.Combobox.combobox.data
--@JavaScript AuthorityUrrelation.Combobox.combobox.SQL
select t1.N_UID "n_uid",
t1.N_RID "n_rid",
t1.C_CTIME "c_ctime",
t1.C_CIP "c_cip",
t1.C_CREATOR "c_creator"
from tool.t_authority_urrelation t1
--HQL select AuthorityUrrelation.Combobox.combobox.data
--@JavaScript AuthorityUrrelation.Combobox.combobox.HQL
--@JavaScript AuthorityUrrelation.Combobox.combobox.JPQL
--@JavaScript AuthorityUrrelation.Export.export.SQL
select t1.N_UID "n_uid",
t1.N_RID "n_rid",
t1.C_CTIME "c_ctime",
t1.C_CIP "c_cip",
t1.C_CREATOR "c_creator"
from tool.t_authority_urrelation t1
--@JavaScript AuthorityUrrelation.Export.export.HQL
--@JavaScript AuthorityUrrelation.Export.export.JPQL
--@JavaScript AuthorityUrrelation.Nest.nest.SQL
/**
select *
from tool.t_authority_level t2
where t2.name = t1.name**/
--@JavaScript AuthorityUrrelation.Nest.nest.HQL
--@JavaScript AuthorityUrrelation.Nest.nest.JPQL
| true |
02a873e1dbde7748e94c13ea5d8ec8b44e4f4f46 | SQL | demidielon/geekbrains-mysql | /stream1/2/5ad5db872e27476ef3e2f69b0f75106b9ec96526.sql | UTF-8 | 2,288 | 3.25 | 3 | [] | no_license | ALTER TABLE `world`.`country`
DROP FOREIGN KEY `fk_capital`;
ALTER TABLE `world`.`country`
DROP COLUMN `IsDeleted`,
DROP COLUMN `DateUpdate`,
DROP COLUMN `Population`,
DROP COLUMN `Langudge`,
DROP COLUMN `CapitalCity`,
DROP COLUMN `Founded`,
DROP COLUMN `TextCode`,
DROP COLUMN `NumCode`,
CHANGE COLUMN `ID` `id` INT NOT NULL AUTO_INCREMENT ,
CHANGE COLUMN `Name` `title` VARCHAR(150) NOT NULL COMMENT '\nInternational name' ,
DROP INDEX `fk_capital_idx` ,
DROP INDEX `TextCode_UNIQUE` ,
DROP INDEX `NumCode_UNIQUE` ;
ALTER TABLE `world`.`region`
DROP FOREIGN KEY `fk_country`,
DROP FOREIGN KEY `fk_adm_center`;
ALTER TABLE `world`.`region`
DROP COLUMN `IsDeleted`,
DROP COLUMN `DateUpdate`,
DROP COLUMN `Population`,
DROP COLUMN `AdmCenter`,
DROP COLUMN `NumCode`,
DROP COLUMN `TextCode`,
CHANGE COLUMN `ID` `id` INT NOT NULL AUTO_INCREMENT ,
CHANGE COLUMN `CountryID` `сountry_id` INT NOT NULL COMMENT '\nA foreign key identifying the country from the \"country\" table' ,
CHANGE COLUMN `Name` `title` VARCHAR(150) NOT NULL ,
DROP INDEX `fk_adm_center_idx` ,
DROP INDEX `NumCode_UNIQUE` ,
DROP INDEX `TextCode_UNIQUE` ;
ALTER TABLE `world`.`region`
ADD CONSTRAINT `fk_country`
FOREIGN KEY (`сountry_id`)
REFERENCES `world`.`country` (`ID`)
ON DELETE CASCADE
ON UPDATE CASCADE;
ALTER TABLE `world`.`city`
DROP FOREIGN KEY `fk_country2`,
DROP FOREIGN KEY `fk_region1`,
DROP FOREIGN KEY `fk_area`;
ALTER TABLE `world`.`city`
DROP COLUMN `DateUpdate`,
DROP COLUMN `Population`,
DROP COLUMN `AreaID`,
CHANGE COLUMN `ID` `id` INT NOT NULL AUTO_INCREMENT ,
CHANGE COLUMN `CoutryID` `coutry_id` INT NOT NULL COMMENT 'A foreign key identifying the country from the \"country\" table' ,
CHANGE COLUMN `RegionID` `region_id` INT NOT NULL COMMENT 'A foreign key identifying the region from the \"region\" table' ,
CHANGE COLUMN ` Name` `title` VARCHAR(150) NOT NULL ,
CHANGE COLUMN `IsDeleted` `important` TINYINT(1) NOT NULL ,
DROP INDEX `fk_area_idx` ;
ALTER TABLE `world`.`city`
ADD CONSTRAINT `fk_country2`
FOREIGN KEY (`coutry_id`)
REFERENCES `world`.`country` (`ID`)
ON DELETE CASCADE
ON UPDATE CASCADE,
ADD CONSTRAINT `fk_region1`
FOREIGN KEY (`region_id`)
REFERENCES `world`.`region` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE;
drop table `world`.`area` | true |
4116fa7b0e4e2ef863f8646313a5a6d287159fb0 | SQL | LucaROC/I8AO3 | /Sprint 7 Opdrachten/SQL/Subqueries/[4] Eventful countries (Niet volgens opdracht, nog ff naar kijken).sql | UTF-8 | 192 | 3.546875 | 4 | [] | no_license | USE WorldEvents
SELECT
CountryName
FROM
tblCountry INNER JOIN tblEvent ON
tblCountry.CountryID = tblEvent.CountryID
GROUP BY
CountryName
HAVING
COUNT(EventName) > 8
| true |
492628bbd2bc6704c3f24c930d1e1e70a4387420 | SQL | jhon-int/SQL | /Jhonatan Dantas - P2.sql | UTF-8 | 3,440 | 3.890625 | 4 | [] | no_license | /*1- insert itens_nfv*/
DELIMITER //
DROP TRIGGER IF EXISTS valor_prod //
CREATE TRIGGER valor_prod
BEFORE INSERT ON itens_nfv
FOR EACH ROW
BEGIN
IF ((SELECT produtos.estoque FROM produtos WHERE produtos.id_produto = new.id_produto) > 100) THEN
SET new.valor = (SELECT produtos.venda*0.95 FROM produtos WHERE produtos.id_produto = new.id_produto);
END IF;
IF ((SELECT produtos.estoque FROM produtos WHERE produtos.id_produto = new.id_produto) <= 100) THEN
SET new.valor = (SELECT produtos.venda FROM produtos WHERE produtos.id_produto = new.id_produto);
END IF;
END;
//
DELIMITER ;
INSERT INTO itens_nfv (valor, quantidade, id_nfv, id_produto)
VALUES (500, 5, 1, 1)
/*2- update nfv*/
DELIMITER //
DROP TRIGGER IF EXISTS atualiza_nfv //
CREATE TRIGGER atualiza_nfv
AFTER UPDATE ON itens_nfv
FOR EACH ROW
BEGIN
UPDATE nfv
SET nfv.valor = new.valor * new.quantidade
WHERE nfv.id_nfv = new.id_nfv;
END;
//
DELIMITER ;
/*3- insert nfv*/
DELIMITER //
DROP TRIGGER IF EXISTS desc_nfv //
CREATE TRIGGER desc_nfv
BEFORE INSERT ON nfv
FOR EACH ROW
BEGIN
IF ((SELECT nfv.valor FROM nfv WHERE nfv.id_nfv = new.id_nfv) < 200) THEN
SET new.valor = new.valor * 0.95;
END IF;
IF ((SELECT nfv.valor FROM nfv WHERE nfv.id_nfv = new.id_nfv) > 200 && (SELECT nfv.valor FROM nfv WHERE nfv.id_nfv = new.id_nfv) > 500) THEN
SET new.valor = new.valor * 0.92;
END IF;
IF ((SELECT nfv.valor FROM nfv WHERE nfv.id_nfv = new.id_nfv) > 500) THEN
SET new.valor = new.valor * 0.9;
END IF;
END;
//
DELIMITER ;
INSERT INTO (emissao, valor, id_vendedor, id_cliente, id_fp)
VALUES ('2018.05.02', 190, 1, 1, 1)
/*4- entrar codigo, sair razao social, total de produtos*/
DELIMITER //
DROP PROCEDURE IF EXISTS forn_emp //
CREATE PROCEDURE forn_emp (IN cod INT, OUT razao VARCHAR(50), OUT total_prod INT)
BEGIN
IF(cod IN (SELECT fornecedores.id_fornecedor FROM fornecedores))THEN
IF(cod IN (SELECT nfc.id_fornecedor FROM nfc WHERE nfc.id_fornecedor = cod))THEN
SELECT
fornecedores.razaos,
COUNT(nfc.id_fornecedor)
FROM fornecedores
INNER JOIN nfc ON(fornecedores.id_fornecedor = nfc.id_fornecedor)
INTO razao, total_prod;
ELSE
SELECT "fornecedor não associado a nenhum produto" AS Mensagem;
END IF;
ELSE
SELECT "fornecedor não existe" AS Mensagem;
END IF;
END;
//
DELIMITER ;
/*5- in*/
DELIMITER //
DROP PROCEDURE IF EXISTS total_vend //
CREATE PROCEDURE total_vend (IN cod INT, datainicial DATE, datafinal DATE)
BEGIN
IF(cod IN (SELECT produtos.id_produto FROM produtos))THEN
IF(EXISTS(SELECT nfv.emissao FROM nfv WHERE nfv.emissao BETWEEN datainicial AND datafinal))THEN
IF(cod IN (SELECT itens_nfv.id_nfv FROM itens_nfv WHERE itens_nfv.id_produto = cod))THEN
SELECT DISTINCT
itens_nfv.id_produto,
produtos.descritivo,
SUM(itens_nfv.quantidade),
categorias.descritivo
FROM itens_nfv
INNER JOIN produtos ON(produtos.id_produto = itens_nfv.id_produto)
INNER JOIN categorias ON(categorias.id_categoria = produtos.id_categoria)
WHERE itens_nfv.id_produto = cod;
ELSE
SELECT "nao ouve vendas deste produto" AS Mensagem;
END IF;
ELSE
SELECT "nao ouve vendas neste pediodo" AS Mensagem;
END IF;
ELSE
SELECT "produto nao cadastrado" AS Mensagem;
END IF;
END;
//
DELIMITER ;
CALL total_vend(1, '2016/01/01', '2018/01/01'); | true |
9e520edacabf811add3a9ebf25e5f5485ebe7598 | SQL | sonminho/spring-project | /movie/test.sql | UTF-8 | 2,366 | 3.109375 | 3 | [] | no_license | <<<<<<< HEAD
DROP TABLE MEMBER;
CREATE TABLE MEMBER(
USER_ID VARCHAR2(10 CHAR) PRIMARY KEY,
PASSWORD VARCHAR2(256 CHAR),
NAME VARCHAR2(20 CHAR), SALT VARCHAR2(16),
USER_LEVEL VARCHAR2(20 CHAR),
EMAIL VARCHAR2(40 CHAR),
PHONE VARCHAR2(20 CHAR),
ADDRESS VARCHAR2(200 CHAR),
REG_DATE DATE DEFAULT sysdate,
UPDATE_DATE DATE DEFAULT sysdate
);
drop table genre;
create table genre(
id number primary key not null,
name varchar(20) not null
);
drop sequence genre_seq;
create SEQUENCE genre_seq
increment by 1
start with 1;
drop table movie;
create table movie(
id number primary key not null,
GENRE_ID number references genre(id),
title varchar2(50) not null,
audience number default 0,
poster_url varchar2(140),
description varchar2(800)
);
drop sequence movie_seq;
create sequence movie_seq
increment by 1
start with 1;
drop table score;
create table score(
id number primary key not null,
movie_id number references movie(id) on delete cascade,
content varchar2(40),
score number
);
drop sequence score_seq;
create sequence score_seq
increment by 1
start with 1;
=======
DROP TABLE MEMBER;
CREATE TABLE MEMBER(
USER_ID VARCHAR2(10 CHAR) PRIMARY KEY,
PASSWORD VARCHAR2(256 CHAR),
NAME VARCHAR2(20 CHAR), SALT VARCHAR2(16),
USER_LEVEL VARCHAR2(20 CHAR),
EMAIL VARCHAR2(40 CHAR),
PHONE VARCHAR2(20 CHAR),
ADDRESS VARCHAR2(200 CHAR),
REG_DATE DATE DEFAULT sysdate,
UPDATE_DATE DATE DEFAULT sysdate
);
drop table genre;
create table genre(
id number primary key not null,
name varchar(20) not null
);
drop sequence genre_seq;
create SEQUENCE genre_seq
increment by 1
start with 1;
drop table movie;
create table movie(
id number primary key not null,
GENRE_ID number references genre(id),
title varchar2(50) not null,
audience number default 0,
poster_url varchar2(140),
description varchar2(800)
);
drop sequence movie_seq;
create sequence movie_seq
increment by 1
start with 1;
drop table score;
create table score(
id number primary key not null,
movie_id number references movie(id) on delete cascade,
content varchar2(40),
score number
);
drop sequence score_seq;
create sequence score_seq
increment by 1
start with 1;
>>>>>>> fb93a14e8e11a9884be0fe1e855f47c615ec6548
| true |
2657b1eff3b133025bbff408a00daa8d5fb959ff | SQL | Mongker/htdocs | /K3Office/database/visa.sql | UTF-8 | 2,199 | 3 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 4.9.2
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Dec 31, 2019 at 06:28 PM
-- Server version: 10.4.10-MariaDB
-- PHP Version: 7.1.33
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `k3office`
--
-- --------------------------------------------------------
--
-- Table structure for table `visa`
--
CREATE TABLE `visa` (
`id` int(11) NOT NULL COMMENT 'Khóa tự tăng',
`dauthe` varchar(30) COLLATE utf8_unicode_ci NOT NULL COMMENT 'Đầu thẻ',
`ngaylam` date NOT NULL COMMENT 'Ngày làm',
`khachang` varchar(100) COLLATE utf8_unicode_ci NOT NULL COMMENT 'Khách Hàng',
`sothe` varchar(15) COLLATE utf8_unicode_ci NOT NULL COMMENT 'số tiền làm',
`sotienlam` float NOT NULL COMMENT 'số tiền làm',
`nht` float NOT NULL COMMENT 'Phí % ngân hàng thu',
`kh` float NOT NULL COMMENT 'Phí % thu khách hàng',
`psum` float NOT NULL COMMENT 'Phí thu tổng',
`ptnh` float NOT NULL COMMENT 'Phí thu ngân hàng',
`ptkh` float NOT NULL COMMENT 'Phí thu khách hàng'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
--
-- Dumping data for table `visa`
--
INSERT INTO `visa` (`id`, `dauthe`, `ngaylam`, `khachang`, `sothe`, `sotienlam`, `nht`, `kh`, `psum`, `ptnh`, `ptkh`) VALUES
(4, 'Le', '2020-01-01', 'Mong', '1223', 6000000, 1.1, 0.02, 120000, 66000, 54000);
--
-- Indexes for dumped tables
--
--
-- Indexes for table `visa`
--
ALTER TABLE `visa`
ADD PRIMARY KEY (`id`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `visa`
--
ALTER TABLE `visa`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Khóa tự tăng', AUTO_INCREMENT=5;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
| true |
bc3942e2e03e5ac07189ad93084cdf2c395ceb75 | SQL | Last-Mile-Health/LMD-Databases | /lastmile_chwdb/views/training/view_trainingStaffCompletedByRows.sql | UTF-8 | 994 | 3.625 | 4 | [] | no_license | use lastmile_chwdb;
drop view if exists view_trainingStaffCompletedByRows;
create view view_trainingStaffCompletedByRows as
select
t.staffID,
t.firstName,
t.lastName,
t.gender,
t.datePositionBegan,
t.datePositionEnded,
t.title,
t.trainingType,
p.participantID,
p.participantPosition,
p.participantTrainingType,
p.trainingDate
from view_trainingStaffTrainingType as t
left outer join view_trainingResultsRecord as p
on ( t.staffID = p.participantID ) and
( trim( t.title ) like ( if( trim( p.participantPosition ) like 'CHW Leader', 'CHWL',
if( trim( p.participantPosition ) like 'CHW-L', 'CHWL',
trim( p.participantPosition ) ) )
)
) and
( trim( t.trainingType ) like trim( p.participantTrainingType ) )
;
| true |
7f8714ea478edab8f99aec6e4d6cc8491c094ec2 | SQL | JayDeeJaye/activity-logger | /database/ACTIVITY_TRACKER_db.sql | UTF-8 | 2,331 | 3.5625 | 4 | [
"Apache-2.0"
] | permissive | --
-- Database for the ActivityTracker application
--
-- To install on your server
-- Update the options below to match your environment
-- Run this script as your MySQL administrator
-- Create an application user with SELECT, UPDATE, DELETE, INSERT
-- on all tables
-- Updated connectvars.php with application username and password
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
--
-- Database: `activity_tracker`
--
CREATE DATABASE IF NOT EXISTS `activity_tracker` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
USE `activity_tracker`;
-- --------------------------------------------------------
--
-- Table structure for table `activity`
--
CREATE TABLE IF NOT EXISTS `activity` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11) DEFAULT NULL,
`activity_name` varchar(60) DEFAULT NULL,
`priority` varchar(30) DEFAULT NULL,
`estimate` decimal(10,0) DEFAULT NULL,
`status` varchar(30) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ;
-- --------------------------------------------------------
--
-- Table structure for table `activity_log`
--
CREATE TABLE IF NOT EXISTS `activity_log` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11) DEFAULT NULL,
`activity_id` int(11) DEFAULT NULL,
`start_time` datetime NOT NULL,
`elapsed_time` decimal(10,4) DEFAULT NULL,
`confirmed` varchar(1) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ;
-- --------------------------------------------------------
--
-- Table structure for table `member`
--
CREATE TABLE IF NOT EXISTS `member` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(60) DEFAULT NULL,
`real_name` varchar(60) DEFAULT NULL,
`email_address` varchar(60) DEFAULT NULL,
`password` varchar(120) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
| true |
5fcb16c7a5a2d0d4984ad94402f1b5ed40cde645 | SQL | faiz-anwar4749/EmployeePayrollDB | /UC7-AggregateFunctions_PayrollService.sql | UTF-8 | 585 | 3.375 | 3 | [] | no_license | --UC7-aggregate function
USE payroll_service
SELECT * FROM employee_payroll
SELECT SUM(salary) AS Total_Salary FROM employee_payroll GROUP BY gender;
SELECT AVG(salary) AS Average_Salary FROM employee_payroll GROUP BY gender;
SELECT MIN(salary) AS Minimum_Salary FROM employee_payroll GROUP BY gender;
SELECT MAX(salary) AS Maximum_Salary FROM employee_payroll GROUP BY gender;
SELECT COUNT(salary) AS Count_M FROM employee_payroll WHERE gender='M' GROUP BY gender;
SELECT COUNT(salary) AS Count_F FROM employee_payroll WHERE gender='F' GROUP BY gender;
SELECT * FROM employee_payroll; | true |
939b9988aecad814d721ba012850fbaf0bca081d | SQL | BenRKarl/WDI_work | /w03/d03/Dmitry_Shamis/homework/domain_modeling/grocery.sql | UTF-8 | 417 | 2.703125 | 3 | [] | no_license | -- Notes
CREATE DATABASE grocery;
\c grocery
CREATE TABLE libations
(
id serial4 PRIMARY KEY,
libations_type varchar(255)
);
CREATE TABLE comestibles
(
id serial4 PRIMARY KEY,
comestibles_type varchar(255)
);
CREATE TABLE food_types
(
id serial4 PRIMARY KEY,
category varchar(255),
food_type_id integer
);
Is a drink sold under comestibles? Is booze not a drink?
Is ice cream dairy or a snack?
| true |
91f95afdfeaf5f0c3bd70010b4a9b55cabd5089c | SQL | brentrichards/MIMIC-IV-Win | /concepts_PG_local/comorbidity/charlson_pg.sql | UTF-8 | 11,846 | 3.484375 | 3 | [
"MIT"
] | permissive | -- ------------------------------------------------------------------
-- This query extracts Charlson Comorbidity Index (CCI) based on the recorded ICD-9 and ICD-10 codes.
--
-- Reference for CCI:
-- (1) Charlson ME, Pompei P, Ales KL, MacKenzie CR. (1987) A new method of classifying prognostic
-- comorbidity in longitudinal studies: development and validation.J Chronic Dis; 40(5):373-83.
--
-- (2) Charlson M, Szatrowski TP, Peterson J, Gold J. (1994) Validation of a combined comorbidity
-- index. J Clin Epidemiol; 47(11):1245-51.
--
-- Reference for ICD-9-CM and ICD-10 Coding Algorithms for Charlson Comorbidities:
-- (3) Quan H, Sundararajan V, Halfon P, et al. Coding algorithms for defining Comorbidities in ICD-9-CM
-- and ICD-10 administrative data. Med Care. 2005 Nov; 43(11): 1130-9.
-- ------------------------------------------------------------------
WITH diag AS
(
SELECT
hadm_id
, CASE WHEN icd_version = 9 THEN icd_code ELSE NULL END AS icd9_code
, CASE WHEN icd_version = 10 THEN icd_code ELSE NULL END AS icd10_code
FROM mimic_hosp.diagnoses_icd diag
)
, com AS
(
SELECT
ad.hadm_id
-- Myocardial infarction
, MAX(CASE WHEN
SUBSTR(icd9_code, 1, 3) IN ('410','412')
OR
SUBSTR(icd10_code, 1, 3) IN ('I21','I22')
OR
SUBSTR(icd10_code, 1, 4) = 'I252'
THEN 1
ELSE 0 END) AS myocardial_infarct
-- Congestive heart failure
, MAX(CASE WHEN
SUBSTR(icd9_code, 1, 3) = '428'
OR
SUBSTR(icd9_code, 1, 5) IN ('39891','40201','40211','40291','40401','40403',
'40411','40413','40491','40493')
OR
SUBSTR(icd9_code, 1, 4) BETWEEN '4254' AND '4259'
OR
SUBSTR(icd10_code, 1, 3) IN ('I43','I50')
OR
SUBSTR(icd10_code, 1, 4) IN ('I099','I110','I130','I132','I255','I420',
'I425','I426','I427','I428','I429','P290')
THEN 1
ELSE 0 END) AS congestive_heart_failure
-- Peripheral vascular disease
, MAX(CASE WHEN
SUBSTR(icd9_code, 1, 3) IN ('440','441')
OR
SUBSTR(icd9_code, 1, 4) IN ('0930','4373','4471','5571','5579','V434')
OR
SUBSTR(icd9_code, 1, 4) BETWEEN '4431' AND '4439'
OR
SUBSTR(icd10_code, 1, 3) IN ('I70','I71')
OR
SUBSTR(icd10_code, 1, 4) IN ('I731','I738','I739','I771','I790',
'I792','K551','K558','K559','Z958','Z959')
THEN 1
ELSE 0 END) AS peripheral_vascular_disease
-- Cerebrovascular disease
, MAX(CASE WHEN
SUBSTR(icd9_code, 1, 3) BETWEEN '430' AND '438'
OR
SUBSTR(icd9_code, 1, 5) = '36234'
OR
SUBSTR(icd10_code, 1, 3) IN ('G45','G46')
OR
SUBSTR(icd10_code, 1, 3) BETWEEN 'I60' AND 'I69'
OR
SUBSTR(icd10_code, 1, 4) = 'H340'
THEN 1
ELSE 0 END) AS cerebrovascular_disease
-- Dementia
, MAX(CASE WHEN
SUBSTR(icd9_code, 1, 3) = '290'
OR
SUBSTR(icd9_code, 1, 4) IN ('2941','3312')
OR
SUBSTR(icd10_code, 1, 3) IN ('F00','F01','F02','F03','G30')
OR
SUBSTR(icd10_code, 1, 4) IN ('F051','G311')
THEN 1
ELSE 0 END) AS dementia
-- Chronic pulmonary disease
, MAX(CASE WHEN
SUBSTR(icd9_code, 1, 3) BETWEEN '490' AND '505'
OR
SUBSTR(icd9_code, 1, 4) IN ('4168','4169','5064','5081','5088')
OR
SUBSTR(icd10_code, 1, 3) BETWEEN 'J40' AND 'J47'
OR
SUBSTR(icd10_code, 1, 3) BETWEEN 'J60' AND 'J67'
OR
SUBSTR(icd10_code, 1, 4) IN ('I278','I279','J684','J701','J703')
THEN 1
ELSE 0 END) AS chronic_pulmonary_disease
-- Rheumatic disease
, MAX(CASE WHEN
SUBSTR(icd9_code, 1, 3) = '725'
OR
SUBSTR(icd9_code, 1, 4) IN ('4465','7100','7101','7102','7103',
'7104','7140','7141','7142','7148')
OR
SUBSTR(icd10_code, 1, 3) IN ('M05','M06','M32','M33','M34')
OR
SUBSTR(icd10_code, 1, 4) IN ('M315','M351','M353','M360')
THEN 1
ELSE 0 END) AS rheumatic_disease
-- Peptic ulcer disease
, MAX(CASE WHEN
SUBSTR(icd9_code, 1, 3) IN ('531','532','533','534')
OR
SUBSTR(icd10_code, 1, 3) IN ('K25','K26','K27','K28')
THEN 1
ELSE 0 END) AS peptic_ulcer_disease
-- Mild liver disease
, MAX(CASE WHEN
SUBSTR(icd9_code, 1, 3) IN ('570','571')
OR
SUBSTR(icd9_code, 1, 4) IN ('0706','0709','5733','5734','5738','5739','V427')
OR
SUBSTR(icd9_code, 1, 5) IN ('07022','07023','07032','07033','07044','07054')
OR
SUBSTR(icd10_code, 1, 3) IN ('B18','K73','K74')
OR
SUBSTR(icd10_code, 1, 4) IN ('K700','K701','K702','K703','K709','K713',
'K714','K715','K717','K760','K762',
'K763','K764','K768','K769','Z944')
THEN 1
ELSE 0 END) AS mild_liver_disease
-- Diabetes without chronic complication
, MAX(CASE WHEN
SUBSTR(icd9_code, 1, 4) IN ('2500','2501','2502','2503','2508','2509')
OR
SUBSTR(icd10_code, 1, 4) IN ('E100','E10l','E106','E108','E109','E110','E111',
'E116','E118','E119','E120','E121','E126','E128',
'E129','E130','E131','E136','E138','E139','E140',
'E141','E146','E148','E149')
THEN 1
ELSE 0 END) AS diabetes_without_cc
-- Diabetes with chronic complication
, MAX(CASE WHEN
SUBSTR(icd9_code, 1, 4) IN ('2504','2505','2506','2507')
OR
SUBSTR(icd10_code, 1, 4) IN ('E102','E103','E104','E105','E107','E112','E113',
'E114','E115','E117','E122','E123','E124','E125',
'E127','E132','E133','E134','E135','E137','E142',
'E143','E144','E145','E147')
THEN 1
ELSE 0 END) AS diabetes_with_cc
-- Hemiplegia or paraplegia
, MAX(CASE WHEN
SUBSTR(icd9_code, 1, 3) IN ('342','343')
OR
SUBSTR(icd9_code, 1, 4) IN ('3341','3440','3441','3442',
'3443','3444','3445','3446','3449')
OR
SUBSTR(icd10_code, 1, 3) IN ('G81','G82')
OR
SUBSTR(icd10_code, 1, 4) IN ('G041','G114','G801','G802','G830',
'G831','G832','G833','G834','G839')
THEN 1
ELSE 0 END) AS paraplegia
-- Renal disease
, MAX(CASE WHEN
SUBSTR(icd9_code, 1, 3) IN ('582','585','586','V56')
OR
SUBSTR(icd9_code, 1, 4) IN ('5880','V420','V451')
OR
SUBSTR(icd9_code, 1, 4) BETWEEN '5830' AND '5837'
OR
SUBSTR(icd9_code, 1, 5) IN ('40301','40311','40391','40402','40403','40412','40413','40492','40493')
OR
SUBSTR(icd10_code, 1, 3) IN ('N18','N19')
OR
SUBSTR(icd10_code, 1, 4) IN ('I120','I131','N032','N033','N034',
'N035','N036','N037','N052','N053',
'N054','N055','N056','N057','N250',
'Z490','Z491','Z492','Z940','Z992')
THEN 1
ELSE 0 END) AS renal_disease
-- Any malignancy, including lymphoma and leukemia, except malignant neoplasm of skin
, MAX(CASE WHEN
SUBSTR(icd9_code, 1, 3) BETWEEN '140' AND '172'
OR
SUBSTR(icd9_code, 1, 4) BETWEEN '1740' AND '1958'
OR
SUBSTR(icd9_code, 1, 3) BETWEEN '200' AND '208'
OR
SUBSTR(icd9_code, 1, 4) = '2386'
OR
SUBSTR(icd10_code, 1, 3) IN ('C43','C88')
OR
SUBSTR(icd10_code, 1, 3) BETWEEN 'C00' AND 'C26'
OR
SUBSTR(icd10_code, 1, 3) BETWEEN 'C30' AND 'C34'
OR
SUBSTR(icd10_code, 1, 3) BETWEEN 'C37' AND 'C41'
OR
SUBSTR(icd10_code, 1, 3) BETWEEN 'C45' AND 'C58'
OR
SUBSTR(icd10_code, 1, 3) BETWEEN 'C60' AND 'C76'
OR
SUBSTR(icd10_code, 1, 3) BETWEEN 'C81' AND 'C85'
OR
SUBSTR(icd10_code, 1, 3) BETWEEN 'C90' AND 'C97'
THEN 1
ELSE 0 END) AS malignant_cancer
-- Moderate or severe liver disease
, MAX(CASE WHEN
SUBSTR(icd9_code, 1, 4) IN ('4560','4561','4562')
OR
SUBSTR(icd9_code, 1, 4) BETWEEN '5722' AND '5728'
OR
SUBSTR(icd10_code, 1, 4) IN ('I850','I859','I864','I982','K704','K711',
'K721','K729','K765','K766','K767')
THEN 1
ELSE 0 END) AS severe_liver_disease
-- Metastatic solid tumor
, MAX(CASE WHEN
SUBSTR(icd9_code, 1, 3) IN ('196','197','198','199')
OR
SUBSTR(icd10_code, 1, 3) IN ('C77','C78','C79','C80')
THEN 1
ELSE 0 END) AS metastatic_solid_tumor
-- AIDS/HIV
, MAX(CASE WHEN
SUBSTR(icd9_code, 1, 3) IN ('042','043','044')
OR
SUBSTR(icd10_code, 1, 3) IN ('B20','B21','B22','B24')
THEN 1
ELSE 0 END) AS aids
FROM mimic_core.admissions ad
LEFT JOIN diag
ON ad.hadm_id = diag.hadm_id
GROUP BY ad.hadm_id
)
, ag AS
(
SELECT
hadm_id
, age
, CASE WHEN age <= 40 THEN 0
WHEN age <= 50 THEN 1
WHEN age <= 60 THEN 2
WHEN age <= 70 THEN 3
ELSE 4 END AS age_score
FROM mimiciv.age_mv
)
SELECT
ad.subject_id
, ad.hadm_id
, ag.age_score
, myocardial_infarct
, congestive_heart_failure
, peripheral_vascular_disease
, cerebrovascular_disease
, dementia
, chronic_pulmonary_disease
, rheumatic_disease
, peptic_ulcer_disease
, mild_liver_disease
, diabetes_without_cc
, diabetes_with_cc
, paraplegia
, renal_disease
, malignant_cancer
, severe_liver_disease
, metastatic_solid_tumor
, aids
-- Calculate the Charlson Comorbidity Score using the original
-- weights from Charlson, 1987.
, age_score
+ myocardial_infarct + congestive_heart_failure + peripheral_vascular_disease
+ cerebrovascular_disease + dementia + chronic_pulmonary_disease
+ rheumatic_disease + peptic_ulcer_disease
+ GREATEST(mild_liver_disease, 3*severe_liver_disease)
+ GREATEST(2*diabetes_with_cc, diabetes_without_cc)
+ GREATEST(2*malignant_cancer, 6*metastatic_solid_tumor)
+ 2*paraplegia + 2*renal_disease
+ 6*aids
AS charlson_comorbidity_index
FROM mimic_core.admissions ad
LEFT JOIN com
ON ad.hadm_id = com.hadm_id
LEFT JOIN ag
ON com.hadm_id = ag.hadm_id
;
| true |
b3910dcdee6be8f2ddf538759996dadd6a131e13 | SQL | liwen666/lw_code | /tempcode/src/main/java/commons/execscript/sql/bgt/common/common_164_.sql | GB18030 | 685 | 2.84375 | 3 | [] | no_license | declare
v_n1 number(8) := 0;
begin
select count(1)
into v_n1
from user_views
where upper(view_name) = 'BGT_T_CUSTOMSORT';
if v_n1 = 0 then
execute immediate Q'{create table BGT_T_CUSTOMSORT(ID VARCHAR2(32) default SYS_GUID() not null,GUID VARCHAR2(32) default SYS_GUID() not null,
TABLEID VARCHAR2(32) not null,USERID VARCHAR2(32) NOT NULL,ORDERNUM NUMBER(9) default 0,
ASCFLAG CHAR(1),COL VARCHAR2(30),ISRESERVE CHAR(1))}';
execute immediate 'alter table BGT_T_CUSTOMSORT add constraint PK_BGT_T_CUSTOMSORT primary key (GUID,ID,TABLEID,COL,USERID)';
SYS_P_PARTITION_TABLE('BGT_T_CUSTOMSORT');
end if;
end;
--Զ20161011zq
| true |
916863bdb22e273fc0b7c7bd0ff03d28ad0b8d3e | SQL | iosiginer/AGAST2.0 | /GameUI/Model/DAL/QueryResources/QuestionQueries/q12_false.sql | UTF-8 | 292 | 3.5625 | 4 | [] | no_license | #12false
#Which of the songs made by a band?
SELECT track.name AS 'false_answer'
FROM track JOIN artist_credit_name JOIN artist
WHERE track.artist_credit=artist_credit_name.artist_credit
AND artist_credit_name.artist=artist.id
#type 2 is a band
AND NOT artist.type=2
ORDER BY RAND()
limit 3; | true |
50a1e5876d89d245fb4d8406f72472c940c06448 | SQL | AyshaHamna/Hotel-Reservation | /contact.sql | UTF-8 | 2,077 | 2.984375 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 4.8.3
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1:3306
-- Generation Time: Jul 18, 2020 at 07:43 AM
-- Server version: 5.7.23
-- PHP Version: 7.2.10
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `contact_ms`
--
-- --------------------------------------------------------
--
-- Table structure for table `contact`
--
DROP TABLE IF EXISTS `contact`;
CREATE TABLE IF NOT EXISTS `contact` (
`id` int(6) UNSIGNED NOT NULL AUTO_INCREMENT,
`contact_reference_id` varchar(500) NOT NULL,
`name` varchar(500) NOT NULL,
`email` varchar(500) NOT NULL,
`subject` varchar(500) NOT NULL,
`message` varchar(500) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=111 DEFAULT CHARSET=latin1;
--
-- Dumping data for table `contact`
--
INSERT INTO `contact` (`id`, `contact_reference_id`, `name`, `email`, `subject`, `message`) VALUES
(100, 'c100', 'hamna', 'hamna@gmail', 'test1', 'new insert added.'),
(101, 'baf95', 'hansi', 'hansi@gmail', 'test2', 'check post method.'),
(102, '27c16', 'hamii', 'hamii@gmail', '3rd Test', 'insert via jsp'),
(103, '6cc21', 'hamii', 'hamii@gmail', '2nd Try', 'insert via jsp'),
(104, 'b4a40', 'hamna', 'hamna@gmail.com', '6th Test', 'insert via jsp'),
(105, '1aff8', 'hamna111', 'ddd@sss', 'ddd', 'sss'),
(106, 'e5e27', '', '', '', ''),
(107, '27306', 'ssss', '', 'dfdfd', 'dfdfdf'),
(108, 'eb542', 'Ann', 'ann@gmail', 'Testing', 'Trying out break points'),
(109, '90aee', 'hamii', 'hamii@gmail', 'April Test', 'Testing'),
(110, 'afd77', 'John', 'john@gmail.com', 'Experience', 'The experience was really good');
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
| true |
244094e64c6c498158c8aaf9e605fd2282d0faf7 | SQL | fpugh/DWMgmt | /DWMgmt_SQL_Code/DWMgmt_SQL_DEV_Scripts/20150304_Adhoc_Query_Capture.sql | UTF-8 | 640 | 3.640625 | 4 | [] | no_license |
/* This is a direct method to attach code to query plans,
however produces far too much volume, and too slowly.
Perhaps can adapt for asynchronous query using freetext
methods??
*/
WITH HandleBars (plan_handle, use_counts, objtype, text)
AS (
SELECT t1.plan_handle, t1.usecounts, t1.objtype, t2.text
FROM sys.dm_exec_cached_plans as t1
CROSS APPLY sys.dm_exec_sql_text (plan_handle) as t2
)
SELECT *
FROM CAT.vi_0360_Object_Code_Reference as ocr
CROSS APPLY HandleBars as crap
WHERE ocr.reg_Object_Type NOT IN ('C','D')
AND ocr.reg_code_content <> ''
AND PATINDEX('%'+ocr.reg_code_content+'%', crap.text) > 0
ORDER BY 1 DESC, 2,3 | true |
cbff35436046aea1a2da38f8c86863b46ec11be4 | SQL | bigdatalyn/bigdatalyn.github.io | /12cR2MultitenantHOLCookbook/HOL/app_containers/whereami.sql | UTF-8 | 1,695 | 3.265625 | 3 | [
"MIT"
] | permissive | -- =========================================================================
--
-- File: whereami.sql
-- Author: Patrick G. Wheeler
-- $Revision: 1 $
-- $Date: 2/4/17 7:53p $
-- $Author: PWheeler $ of last update
--
-- Copyright (C) 2017 Oracle Corporation, All rights reserved.
--
-- Purpose:
-- Provide information about current user context.
--
-- Description:
-- Provides information about current user context.
--
-- Dependencies:
-- - Oracle Database 12c Release 12.2 with Multitenant Option.
--
-- This script will be invoked from within SQL Plus.
--
-- ========================================================================
--
column c1 format a15 heading "DB Name"
column c2 format a8 heading "CDB Name"
column c3 format a15 heading "App Root"
column c4 format a15 heading "PDB Name"
column c5 format a9 heading "App_Root?"
column c6 format a5 heading "Seed?"
column c7 format a6 heading "Proxy?"
column c8 format a15 heading "Auth ID"
column c9 format a15 heading "Sessn-User"
select Sys_Context('Userenv', 'DB_Name') c1
, Sys_Context('Userenv', 'CDB_Name') c2
, AR.PDB_Name c3
, My_PDB.PDB_Name c4
, My_PDB.Application_Root c5
, My_PDB.Application_Seed c6
, My_PDB.Is_Proxy_PDB c7
, Sys_Context('Userenv', 'Authenticated_Identity') c8
, Sys_Context('Userenv', 'Session_User') c9
from DBA_PDBs My_PDB
left outer join DBA_PDBs AR
on My_PDB.Application_Root_Con_ID = AR.Con_ID
where My_PDB.PDB_Name = Sys_Context('Userenv', 'Con_Name')
;
| true |
58aa3d23a8843d0afcfd01c0896967b94df93cc7 | SQL | Briareos/Stevo | /schema.sql | UTF-8 | 397 | 3.125 | 3 | [] | no_license | SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
DROP TABLE IF EXISTS `company`;
CREATE TABLE `company` (
`id` int(11) NOT NULL,
`name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
ALTER TABLE `company`
ADD PRIMARY KEY (`id`);
ALTER TABLE `company`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;
| true |
84e7d170273e1ad962d5c5c1c0aa676358c44d5a | SQL | H-daniel00/utn-frc-dlc-2011-liberal-peker-1 | /DLC/clases practica/scripts-comentario/01. estructura.sql | UTF-8 | 1,768 | 3.203125 | 3 | [] | no_license | -- =============================================================================
-- WORD
-- =============================================================================
DROP SEQUENCE IF EXISTS sq_Word CASCADE;
CREATE SEQUENCE sq_Word;
DROP TABLE IF EXISTS Word CASCADE;
CREATE TABLE Word (
id_Word INTEGER NOT NULL,
name_Word VARCHAR(32) NOT NULL,
nr INTEGER NOT NULL,
max_Tf INTEGER NOT NULL,
PRIMARY KEY (id_Word)
);
-- =============================================================================
-- WORD
-- =============================================================================
DROP SEQUENCE IF EXISTS sq_Page CASCADE;
CREATE SEQUENCE sq_Page;
DROP TABLE IF EXISTS Page CASCADE;
CREATE TABLE Page (
id_Url INTEGER NOT NULL,
id_Url_Base INTEGER NOT NULL,
url_Name VARCHAR(32) NOT NULL,
Modulo NUMERIC[6,12] NOT NULL,
PRIMARY KEY (id_Url)
FOREIGN KEY (id_Url_Base)
REFERENCES Page(id_Url)
);
-- =============================================================================
-- PAGE
-- =============================================================================
DROP SEQUENCE IF EXISTS sq_PostList CASCADE;
CREATE SEQUENCE sq_PostList;
DROP TABLE IF EXISTS PostList CASCADE;
CREATE TABLE PostList (
id_Word INTEGER NOT NULL,
id_Url INTEGER NOT NULL,
frequency INTEGER NOT NULL,
PRIMARY KEY (id_Word,id_Url),
FOREIGN KEY (id_Word)
REFERENCES Word(id_Word)
FOREIGN KEY (id_Url)
REFERENCES Page(id_Url),
); | true |
331969220995c6aba30b843e786f763021972880 | SQL | sasabrina/covid-db-v2 | /api-flask/src/db/covid19.sql | UTF-8 | 4,763 | 3.390625 | 3 | [] | no_license | -- MySQL dump 10.13 Distrib 8.0.21, for Linux (x86_64)
--
-- Host: localhost Database: covid19
-- ------------------------------------------------------
-- Server version 8.0.21
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!50503 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `countries`
--
DROP TABLE IF EXISTS `countries`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `countries` (
`id` int NOT NULL AUTO_INCREMENT,
`name` varchar(45) NOT NULL,
`infected` int NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `countries`
--
LOCK TABLES `countries` WRITE;
/*!40000 ALTER TABLE `countries` DISABLE KEYS */;
INSERT INTO `countries` VALUES (1,'Argentina',0),(2,'Brasil',0),(3,'Chile',0),(4,'Uruguay',0);
/*!40000 ALTER TABLE `countries` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `gender`
--
DROP TABLE IF EXISTS `gender`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `gender` (
`id` int NOT NULL AUTO_INCREMENT,
`name` varchar(45) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `gender`
--
LOCK TABLES `gender` WRITE;
/*!40000 ALTER TABLE `gender` DISABLE KEYS */;
INSERT INTO `gender` VALUES (1,'female'),(2,'male'),(3,'nn');
/*!40000 ALTER TABLE `gender` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `infected`
--
DROP TABLE IF EXISTS `infected`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `infected` (
`id` int NOT NULL AUTO_INCREMENT,
`first_name` varchar(45) NOT NULL,
`last_name` varchar(45) NOT NULL,
`age` int NOT NULL,
`infect_date` datetime NOT NULL,
`gender_id` int NOT NULL,
`country_id` int NOT NULL,
`status_id` int NOT NULL,
PRIMARY KEY (`id`),
KEY `fk_country` (`country_id`),
KEY `fk_gender` (`gender_id`),
KEY `fk_status` (`status_id`),
CONSTRAINT `fk_country` FOREIGN KEY (`country_id`) REFERENCES `countries` (`id`),
CONSTRAINT `fk_gender` FOREIGN KEY (`gender_id`) REFERENCES `gender` (`id`),
CONSTRAINT `fk_status` FOREIGN KEY (`status_id`) REFERENCES `infected_status` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `infected`
--
LOCK TABLES `infected` WRITE;
/*!40000 ALTER TABLE `infected` DISABLE KEYS */;
INSERT INTO `infected` VALUES (3,'Brenda','Almaraz',24,'2020-02-13 00:00:00',1,1,1),(4,'Rosa','Almaraz',24,'2020-02-13 00:00:00',1,1,1),(5,'Rosa','Alvarez',24,'2020-02-13 00:00:00',1,1,1),(6,'Sabrina','Alvarez',33,'2020-05-19 06:00:00',1,4,1);
/*!40000 ALTER TABLE `infected` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `infected_status`
--
DROP TABLE IF EXISTS `infected_status`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `infected_status` (
`id` int NOT NULL AUTO_INCREMENT,
`name` varchar(45) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `infected_status`
--
LOCK TABLES `infected_status` WRITE;
/*!40000 ALTER TABLE `infected_status` DISABLE KEYS */;
INSERT INTO `infected_status` VALUES (1,'alive'),(2,'deceased'),(3,'recovered');
/*!40000 ALTER TABLE `infected_status` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2020-08-31 18:10:11
| true |
930d8d88522b3e94b5bb7f22a997839a20c26705 | SQL | gruter/tajo-elasticsearch | /tajo-core/benchmark/simple/groupby2.sql | UTF-8 | 169 | 2.65625 | 3 | [
"Apache-2.0",
"PostgreSQL",
"BSD-3-Clause",
"MIT"
] | permissive | select
l_orderkey, l_linenumber, sum(l_quantity) as sum_qty, max(l_quantity) as max_qty, min(l_quantity) as min_qty
from
lineitem
group by
l_orderkey, l_linenumber | true |
1f3d5e7e326d87b7624307c2bc939a1d5976e81e | SQL | eltonmesquita87/test | /jose-typescript-nodejs-authentication/sql/schedule/billing_center/45-Duplicated Coverage after new policy change.sql | UTF-8 | 1,633 | 3.921875 | 4 | [] | no_license | select distinct policynumber
from
( select
pp.PolicyNumber,
ii.InstallmentNumber,
iic.removed,
ci.CoverageID,
cpc.PolicyChangeType_GCS,
bi.id,
count(1) as 'qtd'
from bc_invoice ivc with (nolock)
left join bctl_invoicestatus ivcs with (nolock) on ivc.status = ivcs.id
inner join bc_invoiceitem ii with (nolock) on ii.invoiceId = ivc.id
inner join bc_policyperiod pp with (nolock) on pp.id = ii.PolicyPeriodID
inner join bc_charge cg with (nolock) on cg.id = ii.chargeId
inner join bc_chargepattern cp with (nolock) on cp.id = cg.ChargePatternID
inner join bc_billinginstruction bi with (nolock) on cg.BillingInstructionID = bi.id
left join bctl_billinginstruction bitl with (nolock) on bi.subtype = bitl.id
inner join bcx_covitem_gcs ci with (nolock) on ci.CovContainer_GCS = cg.CovContainer_GCS
inner join bcx_invoiceitemcoverages_gcs iic with (nolock) on iic.CovItem_GCSID = ci.id and iic.InvoiceItemID = ii.id and iic.chargeId = cg.id
inner join bcx_coveragepolicychange_gcs cpc on cpc.invoiceitemcoveragesid = iic.id
where 1=1
and bi.Subtype in (1)
and cp.chargeCode = 'Premium'
and ivc.retired = 0
and ii.retired = 0
and ii.reversed = 0
and pp.retired = 0
and cp.retired = 0
and isNull(bitl.retired,0) = 0
and ci.retired = 0
and bi.CreateTime > '<month> 00:00:00'
and iic.retired = 0
and cg.reversed = 0
and cp.ChargeCode = 'Premium'
group by pp.policynumber,iic.removed, cpc.PolicyChangeType_GCS, ii.InstallmentNumber, ci.CoverageID, bi.id
having count(1) > 1) a
where 1=1
| true |
6f932652ad3bbdecbe7118feaa474f01a2118f1a | SQL | nadf/JP23 | /dz/urar_silvija.sql | UTF-8 | 1,977 | 3.859375 | 4 | [] | no_license | # 9. Urar Silvija
# Urar popravlja satove.
# Jedan korisnik može uraru donijeti više satova na popravak dok jedan sat može biti više puta na popravku.
# Urar ima šegrta koji sudjeluje u određenim popravcima satova.
# win+r, upisi cmd te zalijepi sljedecu liniju (prilagoditi putanje - diskove)
# c:\xampp\mysql\bin\mysql -uedunova -pedunova < e:\urar_silvija.sql
drop database if exists urar_silvija;
create database urar_silvija;
use urar_silvija;
create table korisnik(
sifra int not null primary key auto_increment,
ime varchar(50),
prezime varchar(50),
broj_mobitela int
);
create table urar(
sifra int not null primary key auto_increment,
korisnik int not null,
segrt int not null,
iban varchar(50)
);
create table segrt(
sifra int not null primary key auto_increment,
korisnik int not null,
iban varchar(50)
);
create table sat(
sifra int not null primary key auto_increment,
naziv varchar(50) not null,
vrsta varchar(50) not null,
vlasnik int not null
);
create table popravak(
sifra int not null primary key auto_increment,
urar int not null,
segrt int,
trajanje varchar(50) not null,
cijena decimal(18,2)
);
create table popravak_sat(
sifra int not null primary key auto_increment,
popravak int not null,
sat int not null
);
alter table urar add foreign key (korisnik) references korisnik(sifra);
alter table urar add foreign key (segrt) references segrt(sifra);
alter table segrt add foreign key (korisnik) references korisnik(sifra);
alter table sat add foreign key (vlasnik) references korisnik(sifra);
alter table popravak add foreign key (urar) references urar(sifra);
alter table popravak add foreign key (segrt) references segrt(sifra);
alter table popravak_sat add foreign key (popravak) references popravak(sifra);
alter table popravak_sat add foreign key (sat) references sat(sifra); | true |
74cf1e21d942e0e832fd9f1f75f71bf6b93cbf89 | SQL | wally-wally/TIL | /05_DB/Programmers_SQL/05_JOIN/오랜 기간 보호한 동물1.sql | UTF-8 | 344 | 4.1875 | 4 | [] | no_license | -- [1]LEFT JOIN 사용
SELECT A.NAME, A.DATETIME
FROM ANIMAL_INS A LEFT JOIN ANIMAL_OUTS B ON A.ANIMAL_ID = B.ANIMAL_ID
WHERE B.ANIMAL_ID IS NULL
ORDER BY A.DATETIME
LIMIT 3
-- [2]NOT IN 사용
-- SELECT NAME, DATETIME
-- FROM ANIMAL_INS A
-- WHERE A.ANIMAL_ID NOT IN ( SELECT B.ANIMAL_ID FROM ANIMAL_OUTS B )
-- ORDER BY A.DATETIME
-- LIMIT 3 | true |
2f522e0c2d9ea1aee3f32900a58ca0c93e53e30a | SQL | KalyaniPatil23/BluepineappleAssignments | /7 June/customers.sql | UTF-8 | 2,572 | 3.703125 | 4 | [] | no_license | CREATE TABLE Customer (
CustomerId integer,
Customername TEXT,
Contactname TEXT,
Address TEXT,
City TEXT,
PostalCode TEXT,
Country TEXT,
MarketCap double
);
INSERT INTO Customer VALUES
(1, 'Patil Grp', 'Sanket Patil', 'Patil Estate Bhor', 'Pune', '411001', 'India', 2789432879),
(2, 'Nikhar Brothers', 'Rahul Nikhar', 'Nikhar Mahal', 'Nagpur', '440001', 'India', 910052879),
(3, 'Gholap Org', 'Gauri Gholap', 'Gholap & Gholap', 'Nashik', '420005', 'India', 89152879),
(4, 'Patil Grp', 'Kalyani Patil', 'Patil Estate Pune', 'Pune', '411001', 'India', 789152879),
(5, 'Punekars', 'Sneha Punekar', 'Pune', 'Pune', '411001', 'India', 25349152879),
(6, 'Malve Grp', 'Pooja Malve', 'Malve Estate', 'Nashik', '420003', 'India',64539152879),
(7, 'Kere Properties', 'Dhanashree Kere', 'Kere Estate', 'Thane', '400080', 'India',2789152879),
(11, 'Patil Grp', 'Sanket Patil', 'Patil Estate Bhor', 'Osaka', '11001', 'Japan',6745352879),
(12, 'Nikhar Brothers', 'Rahul Nikhar', 'Nikhar Mahal', 'Oslo', '40001', 'Norway',27563152879),
(13, 'Gholap Org', 'Gauri Gholap', 'Gholap & Gholap', 'London', 'E0005', 'UK',915867585642879),
(14, 'Patil Grp', 'Kalyani Patil', 'Patil Estate Pune', 'Paris', '11001', 'France',2976789152879),
(15, 'Punekars', 'Sneha Punekar', 'NSW', 'New Jersey', '11001', 'USA',776589152879),
(16, 'Malve Grp', 'Pooja Malve', 'Malve Estate', 'Sydney', '20003', 'Australia',6349152879),
(17, 'Kere Properties', 'Dhanashree Kere', 'Kere Estate', 'Singapore', '422080', 'Singapore',2004552879);
SELECT * FROM Customer;
SELECT Customername, City FROM Customer;
SELECT * FROM Customer
WHERE Country = 'India';
SELECT * FROM Customer
WHERE Country='India' AND City='Pune';
SELECT * FROM Customer
WHERE City='Nashik' OR City='Nagpur';
SELECT * FROM Customer
WHERE NOT Country='India';
SELECT * FROM Customer
WHERE Country='India' AND (City = 'Nagpur' OR City='Thane');
SELECT * FROM Customer
WHERE NOT Country='India' AND NOT Country='USA';
UPDATE Customer
SET Contactname = 'Patil Estate Karad', City='Karad'
WHERE CustomerId=4;
SELECT * FROM Customer
WHERE CustomerId=4;
INSERT INTO Customer(Customername, City, Country) VALUES('Kalyani', 'Karad', 'India');
SELECT * FROM Customer;
DELETE FROM Customer
WHERE City='Karad';
SELECT * FROM Customer;
SELECT COUNT(CustomerId)
FROM Customer
WHERE City='Pune';
SELECT AVG(MarketCap) FROM Customer
WHERE Country = 'USA';
SELECT SUM(MarketCap) FROM Customer
WHERE Country = 'Singapore';
SELECT MAX(MarketCap) FROM Customer
WHERE Country = 'India';
SELECT MIN(MarketCap) FROM Customer
WHERE Country = 'USA';
SELECT * FROM Customer
GROUP BY City;
SELECT COUNT(CustomerId), Country
FROM Customer
GROUP BY Country; | true |
c63ca35039fbc73c5b5472a1a934cc4f974489af | SQL | daniel2483/NextUExercises | /DesarrolloWeb/Modulo_7-InteractuandoConBasesDeDatos/Unidad_1-EstructuraSQL_NoSQL/Ejercicio4-LenguajeSQL-DML/ejercicio/codBase.sql | UTF-8 | 7,110 | 3.65625 | 4 | [] | no_license | CREATE DATABASE golf_db
WITH
OWNER = postgres
ENCODING = 'UTF8'
CONNECTION LIMIT = -1;
CREATE TABLE public.paises
(
id integer NOT NULL,
nombre character varying(45) NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE public.ciudades
(
id integer NOT NULL,
nombre character varying(45) NOT NULL,
latitud character varying(60) NOT NULL,
longitud character varying(60) NOT NULL,
fk_pais integer NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE public.jugadores
(
id integer NOT NULL,
nombre character varying(45) NOT NULL,
apellido character varying(45) NOT NULL,
fecha_nacimiento date NOT NULL,
categoria character varying(45) NOT NULL,
fk_ciudad_origen integer NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE public.posiciones_torneo
(
fk_jugador integer NOT NULL,
fk_torneo integer NOT NULL,
puntuacion_general integer NOT NULL,
golpes_totales integer NOT NULL,
PRIMARY KEY (fk_jugador, fk_torneo)
);
CREATE TABLE public.campos
(
id integer NOT NULL,
nombre character varying(45) NOT NULL,
direccion character varying(45) NOT NULL,
fk_ciudad integer NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE public.tarjetas_torneo
(
fk_torneo integer NOT NULL,
fk_jugador integer NOT NULL,
fk_numero_hoyo integer NOT NULL,
fk_campo integer NOT NULL,
numero_golpes integer NOT NULL,
puntuacion integer NOT NULL,
PRIMARY KEY (fk_torneo, fk_jugador, fk_numero_hoyo, fk_campo)
);
CREATE TABLE public.torneos
(
id integer NOT NULL,
nombre character varying(45) NOT NULL,
fecha date NOT NULL,
premio double precision NOT NULL,
categoria character varying(45) NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE public.hoyos
(
numero integer NOT NULL,
fk_campo integer NOT NULL,
par integer NOT NULL,
dificultad character varying(45) NOT NULL,
PRIMARY KEY (numero, fk_campo)
);
ALTER TABLE public.ciudades
ADD CONSTRAINT fk_ciudades_paises FOREIGN KEY (fk_pais)
REFERENCES public.paises (id);
ALTER TABLE public.jugadores
ADD CONSTRAINT fk_jugadores_ciudad FOREIGN KEY (fk_ciudad_origen)
REFERENCES public.ciudades (id);
ALTER TABLE public.posiciones_torneo
ADD CONSTRAINT fk_posiciones_jugador FOREIGN KEY (fk_jugador)
REFERENCES public.jugadores (id);
ALTER TABLE public.posiciones_torneo
ADD CONSTRAINT fk_posiciones_torneo FOREIGN KEY (fk_torneo)
REFERENCES public.torneos (id);
ALTER TABLE public.tarjetas_torneo
ADD CONSTRAINT fk_tarjetas_torneos FOREIGN KEY (fk_torneo)
REFERENCES public.torneos (id);
ALTER TABLE public.tarjetas_torneo
ADD CONSTRAINT fk_tarjetas_jugador FOREIGN KEY (fk_jugador)
REFERENCES public.jugadores (id);
ALTER TABLE public.tarjetas_torneo
ADD CONSTRAINT fk_tarjetas_hoyo FOREIGN KEY (fk_numero_hoyo, fk_campo)
REFERENCES public.hoyos (numero, fk_campo);
ALTER TABLE public.campos
ADD CONSTRAINT fk_campos_ciudad FOREIGN KEY (fk_ciudad)
REFERENCES public.ciudades (id);
ALTER TABLE public.hoyos
ADD CONSTRAINT fk_hoyos_campos FOREIGN KEY (fk_campo)
REFERENCES public.campos (id);
INSERT INTO paises VALUES (1, 'Francia'), (2, 'España'), (3, 'Portugal');
INSERT INTO ciudades VALUES (1, 'Paris', '48.856684', '2.351826', 1),
(2, 'Marsella', '43.296979', '5.369415', 1),
(3, 'Madrid', '40.416733', '-3.703820', 2),
(4, 'Barcelona', '41.385069', '2.173793', 2),
(5, 'Lisboa', '38.722262', '-9.139397', 3),
(6, 'Oporto', '41.158089', '-8.629861', 3);
INSERT INTO campos VALUES (1, 'Le Champ', 'Av4 87-21', 1),
(2, 'Petites', 'Av1 11-40', 2),
(3, 'Los Robles', 'Av7 22-11', 3),
(4, 'Antienes', 'Av2 25-25', 4),
(5, 'Ouro Preto', 'Av9 10-05', 5),
(6, 'Pedras Brancas', 'Av23 12-51', 6);
INSERT INTO jugadores VALUES (1,'Quin','York','03/17/1977','Semi-profesional',6),
(2,'Alika','Browning','07/12/1978','Semi-profesional',6),
(3,'Zena','Bryan','01/02/1962','Amateur',3),
(4,'Dominique','Mcneil','01/19/1978','Amateur',6),
(5,'Shaeleigh','Brock','08/13/1989','Profesional',2),
(6,'Reed','Skinner','12/24/1968','Profesional',5),
(7,'Deborah','Francis','08/15/1960','Profesional',6),
(8,'Aretha','Gonzales','07/05/1988','Semi-profesional',3),
(9,'Madeline','Chambers','06/07/1992','Profesional',3),
(10,'Kiona','Valdez','10/11/1968','Profesional',5);
INSERT INTO torneos VALUES (1, 'Masters de Paris', '2016-04-12', 400000, 'Semi-profesional'),
(2, 'Abierto de Madrid', '2016-08-30', 800000, 'Profesional');
INSERT INTO tarjetas_torneo VALUES (1, 1, 1, 1, 3, 0),(1, 1, 2, 1, 3, 0),(1, 1, 3, 1, 6, 0),(1, 1, 4, 1, 2, 0),(1, 1, 5, 1, 4, 0),
(1, 1, 6, 1, 1, 0),(1, 1, 7, 1, 3, 0),(1, 1, 8, 1, 5, 0),(1, 1, 9, 1, 4, 0),(1, 1, 10, 1, 2, 0);
INSERT INTO tarjetas_torneo VALUES (1, 1, 11, 1, 3, 0),(1, 1, 12, 1, 2, 0),(1, 1, 13, 1, 5, 0),(1, 1, 14, 1, 3, 0),(1, 1, 15, 1, 7, 0),
(1, 1, 16, 1, 3, 0),(1, 1, 17, 1, 4, 0),(1, 1, 18, 1, 2, 0),(1, 2, 1, 1, 4, 0),(1, 2, 2, 1, 3, 0);
INSERT INTO tarjetas_torneo VALUES (1, 2, 3, 1, 3, 0),(1, 2, 4, 1, 3, 0),(1, 2, 5, 1, 6, 0),(1, 2, 6, 1, 2, 0),(1, 2, 7, 1, 4, 0),
(1, 2, 8, 1, 1, 0),(1, 2, 9, 1, 3, 0),(1, 2, 10, 1, 5, 0),(1, 2, 11, 1, 4, 0),(1, 2, 12, 1, 2, 0);
INSERT INTO tarjetas_torneo VALUES (1, 2, 13, 1, 3, 0),(1, 2, 14, 1, 3, 0),(1, 2, 15, 1, 6, 0),(1, 2, 16, 1, 2, 0),(1, 2, 17, 1, 4, 0),
(1, 2, 18, 1, 1, 0),(1, 4, 1, 1, 3, 0),(1, 4, 2, 1, 5, 0),(1, 4, 3, 1, 4, 0),(1, 4, 4, 1, 2, 0);
INSERT INTO tarjetas_torneo VALUES (1, 4, 5, 1, 3, 0),(1, 4, 6, 1, 3, 0),(1, 4, 7, 1, 6, 0),(1, 4, 8, 1, 2, 0),(1, 4, 9, 1, 4, 0),
(1, 4, 10, 1, 1, 0),(1, 4, 11, 1, 3, 0),(1, 4, 12, 1, 5, 0),(1, 4, 13, 1, 4, 0),(1, 4, 14, 1, 2, 0);
INSERT INTO tarjetas_torneo VALUES (1, 4, 15, 1, 3, 0),(1, 4, 16, 1, 3, 0),(1, 4, 17, 1, 6, 0),(1, 4, 18, 1, 2, 0);
| true |
b975f915abc5042cdc671c7ae6d357ddb9b18c8b | SQL | PPXComputer/Still_Believe_ | /mysqlStudy/MySQL学习总结/08存储过程和函数/updateSql.sql | UTF-8 | 1,004 | 3.703125 | 4 | [] | no_license | -- 更新学生id,返回空
DROP FUNCTION IF EXISTS update_student_id;
DELIMITER $$
CREATE FUNCTION update_student_id() RETURNS varchar(2)
BEGIN
DECLARE cnt int;
SELECT COUNT(*) FROM student WHERE id=1004 INTO cnt;
IF cnt>2 THEN
UPDATE student SET name="hello" WHERE id=1004;
ELSE
UPDATE student SET name="world" WHERE id=1004;
END IF;
return '';
END $$
DELIMITER ;
SELECT update_student_id();
DROP FUNCTION IF EXISTS update_student_id;
-- 更新学生id,返回对应执行逻辑
DROP FUNCTION IF EXISTS update_student_id;
DELIMITER $$
CREATE FUNCTION update_student_id() RETURNS varchar(2)
BEGIN
DECLARE cnt int;
DECLARE str VARCHAR(2) DEFAULT '';
SELECT COUNT(*) FROM student WHERE id=1004 INTO cnt;
IF cnt>2 THEN
UPDATE student SET name="hello" WHERE id=1004;
SET str='1';
ELSE
UPDATE student SET name="world" WHERE id=1004;
SET str='2';
END IF;
return str;
END $$
DELIMITER ;
SELECT update_student_id();
DROP FUNCTION IF EXISTS update_student_id; | true |
f4deb1b417070bc2bdc90239f6f06f329d07dde6 | SQL | Milagro12090/Employee-management-system | /db/seed.sql | UTF-8 | 955 | 3.34375 | 3 | [] | no_license | USE employee_management_db;
INSERT INTO department (name)
VALUES ("IT"),
("Production"),
("Engineering"),
("Accounting"),
("Sales");
INSERT INTO role (title, salary, department_ID)
VALUES ("Manager", 65000, 1),
("IT Tech", 50000, 1),
("Manager", 50000, 2),
("Team Lead", 40000, 2),
("Operator", 30000, 2),
("Manager", 110000 , 3),
("Software Engineer", 85000, 3),
("Lead Engineer", 100000, 3),
("Manager", 85000, 4),
("Accountant", 70000, 4),
("Manager", 100000, 5),
("Sales Lead", 90000, 5),
("Salesperson", 70000, 5);
USE employee_management_db;
INSERT INTO employee (first_name, last_name, role_id, manager_id)
VALUES ("Customgrow", "420", 1, NULL ),
("Buddy", "TheElf", 2, 1),
("Bill", "Gates", 3, NULL),
("Lando", "Calarisian", 4, 3),
("The", "Dude(ceo)", 5, 3),
("Rick", "James", 6, NULL),
("Ron", "Swanson", 7, 6),
("Erlich", "Bachman",8, 6),
("Kodak", "Black", 9, NULL),
("Tyra", "Banks", 10, 9);
| true |
8bef275176db9a40d1e54618c59cc13d44ff298e | SQL | ptrckbnck/SQLChecker | /examples/minimal/Abgaben/abgabe_test_uebung_ok.sql | UTF-8 | 760 | 3.171875 | 3 | [] | no_license | /*%%%%head%%
{
"name": "test_uebung",
"type": "submission",
"authors": [["author1","dfg@yahoo.de","6363484"],["author2","dfg@gmx.de","6083479"]]
}%%*/
/*%%1%%*/
insert into plane
values (5, 2, 'Cessna', 'Cessna 162 Skycatcher');
/*%%2%%*/
CREATE TABLE `crewhotel`
(
`ID` int(11) NOT NULL,
`Name` varchar(45) NOT NULL,
`AddressID` int(11) NOT NULL,
PRIMARY KEY (ID)
);
/*%%3%%*/
insert into crewhotel
values (0, 'Hilton', 1234),
(1, 'Steigenberger', 0001),
(2, 'Bobs Burger', 1010101);
/*%%4%%task%%*/
SELECT FlightNo,
DepartureDateAndTimeUTC
FROM flightexecution
WHERE PlaneID = 2;
/*%%5%%task%%*/
SELECT f.FlightNo,
f.PlaneID
FROM flightexecution f
WHERE FlightDurationInMinutes < 130
ORDER BY FlightNo; | true |
256a4c11207136850dc840d0a299096c65e5f884 | SQL | ecommercedatabasedesign/Final-Project | /1343Projecgt2_Group5.sql | UTF-8 | 7,459 | 3.9375 | 4 | [] | no_license | CREATE TABLE "Store" (
"StoreID" INTEGER PRIMARY KEY NOT NULL,
"Store Name" VARCHAR(20) UNIQUE NOT NULL,
"Contact" VARCHAR(30) NOT NULL
);
CREATE TABLE "Product"(
"ID" CHAR(10) NOT NULL,
"StoreID" INTEGER NOT NULL,
"Price" NUMBER NOT NULL,
"Description" TEXT,
"Inventory" NUMBER,
"Name" CHAR(30),
FOREIGN KEY(StoreID) REFERENCES Store(StoreID),
CONSTRAINT ProductID PRIMARY KEY(ID, StoreID)
);
CREATE TABLE "Order"(
'OrderID' INTEGER PRIMARY KEY,
'BuyerID' INTEGER NOT NULL,
'Price' NUMBER NOT NULL,
'Order_time' TEXT NOT NULL,
'Status' TEXT NOT NULL,
FOREIGN KEY(BuyerID) REFERENCES 'Buyer'('BuyerID')
);
CREATE TABLE "Shipment"(
'TrankingNo' INTEGER PRIMARY KEY,
'OrderID' INTEGER NOT NULL,
'Address_ID' INTEGER NOT NULL,
'Vendor' VARCHAR (20) NOT NULL,
'Status' TEXT NOT NULL,
'Create_time' TEXT NOT NULL,
FOREIGN KEY(OrderID) REFERENCES 'Order'('OrderID'),
FOREIGN KEY(Address_ID) REFERENCES 'Address'('Address_ID')
);
CREATE TABLE "Transaction"(
"TransID" INTEGER PRIMARY KEY NOT NULL,
"ProductID" CHAR(10) NOT NULL,
"StoreID" INTEGER NOT NULL,
"OrderID" INTEGER NOT NULL,
"Price" NUMBER NOT NULL,
"Time" TIME NOT NULL,
"Purchase_amount" NUMBER NOT NULL,
FOREIGN KEY(ProductID, StoreID) REFERENCES Product,
FOREIGN KEY(OrderID) REFERENCES 'Order'(OrderID)
);
CREATE TABLE `Buyer` (
`Name` VARCHAR (20),
`BuyerID` INTEGER NOT NULL,
`UserName` VARCHAR(20) NOT NULL,
`Password` VARCHAR (20) NOT NULL,
PRIMARY KEY(`BuyerID`)
);
CREATE TABLE `Address` (
`Address_ID` INTEGER NOT NULL UNIQUE,
`Address` VARCHAR(255),
`ZipCode` VARCHAR(20),
`City` VARCHAR(20),
`State` VARCHAR(20),
`BuyerID` INTEGER NOT NULL,
FOREIGN KEY(`BuyerID`) REFERENCES `Buyer`(`BuyerID`),
PRIMARY KEY(`Address_ID`,`BuyerID`)
);
CREATE TABLE `PAYMENT` (
`PaymentID` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
`OrderID` INTEGER NOT NULL,
`PayID` INTEGER NOT NULL,
`Amount` INTEGER NOT NULL,
`Status` TEXT NOT NULL,
`Payment_time` TEXT NOT NULL,
`PayerID` INTEGER NOT NULL
);
CREATE TABLE `Payment_Method` (
`PayID` INTEGER NOT NULL,
`Card_number` INTEGER NOT NULL,
`Hold_name` TEXT NOT NULL,
`BuyerID` INTEGER NOT NULL ,
PRIMARY KEY (`PayID`,`BuyerID`)
);
INSERT INTO Store(StoreID, 'Store Name', Contact)
VALUES(1,"Indigo",1234567890),
(2,"sports",1234567892),
(3,"nba",1234567893),
(4,"sun glasses",1234567894),
(5,"Choclate factory",1234567895),
(6,"water factory",1234567896),
(7,"drink factory",1234567897),
(8,"garden",1234567898),
(9,"Computers",1234567899),
(10,"DIY computers",1234567800);
INSERT INTO Product(ID, StoreID, Price, Description, Inventory, Name)
VALUES(1,1,10, 'a book', 10, 'story book'),
(2, 2, 20, 'shoes', 20, 'Nike'),
(3, 3, 50, 'basketball', 100, 'Spalding'),
(4, 4, 100, "glasses", 160, 'Ray-Ban'),
(5, 5, 300, "food", 300, 'Godiva'),
(6, 6, 30, "water", 60, 'smartwater'),
(7, 7, 60, "drink", 3, 'Coke'),
(8, 8, 80, "flowers", 60, 'rose'),
(9, 9, 880, "laptop", 90, 'acer'),
(10, 10, 160, "CPU", 10, 'intel');
INSERT INTO Buyer (Name, BuyerID, UserName, Password)
VALUES("Mary Shelley", 1, "MaryShelley0527", "mslove253812"),
("Karry Wu", 2, "s11218wu", "wukairui0701"),
("Ziqian Huang", 3, "huangziqian1888", "hzq1628888"),
("Minyi Ma", 4, "Minyi2899", "Mym5201314"),
("Robert S", 5, "robbbbby188", "8765423rll");
INSERT INTO 'Order' (OrderID, BuyerID, Price, Order_time, Status)
VALUES(1, 1, 10.00, "18/3/15 18:35", "completed"),
(2, 2, 20.00, "18/3/16 18:35", "pending"),
(3, 3, 50.00, "18/3/17 18:35", "completed"),
(4, 3, 900.00, "18/3/18 18:35", "completed"),
(5, 5, 2700.00, "18/3/19 18:35", "completed"),
(6, 1, 120.00, "18/3/20 18:35", "completed"),
(7, 3, 1500.00, "18/3/21 18:35", "completed"),
(8, 4, 2880.00, "18/3/22 18:35", "pending"),
(9, 2, 880.00, "18/3/23 18:35", "completed"),
(10, 1, 160.00, "18/3/24 18:35", "pending");
INSERT INTO 'Transaction'(TransID, ProductID, StoreID, OrderID, Price, Time, Purchase_amount)
VALUES(20,1,1,1,10,'3/16/2018 18:35',1),
(21,2,2,2,20,'3/17/2018 18:35',1),
(22,3,3,3,50,'3/18/2018 18:35',1),
(23,4,4,4,300,'3/19/2018 18:35',3),
(24,5,5,5,900,'3/20/2018 18:35',3),
(25,6,6,6,60,'3/21/2018 18:35',2),
(26,7,7,7,300,'3/22/2018 18:35',5),
(27,8,8,8,480,'3/23/2018 18:35',6),
(28,9,9,9,880,'3/24/2018 18:35',1),
(29,10,10,10,160,'3/25/2018 18:35',1);
INSERT INTO Address( Address_ID, Address, ZipCode, City, State, BuyerID)
VALUES(1, "736 Bay Street, Unit 1903", "M5G 2M4", "Toronto", "Ontario", 2),
(2, "5566 Center Street, APT 3", "Q2D J1R", "Mississauga", "Ontario", 5),
(3, "5 Horbart Street, APT 11", "P2D G8Q", "Winnipeg", "Manitoba", 5),
(4, "234 Wellington Street, APT 1", "G8G 2H1", "Ottawa", "Ontario",1),
(5, "Carlton Street, APT 1", "M5G Q1G", "Montreal", "Québec", 4);
INSERT INTO Shipment (TrankingNo, OrderID, Address_ID, Vendor, Status, Create_time)
VALUES(1, 1, 4, "UPS", "pending", "18/3/16 19:35"),
(3, 4, 5, "CanadaPost", "pending", "18/3/19 19:35"),
(4, 5, 3, "Fedex", "pending", "18/3/20 19:35");
insert into PAYMENT (PaymentID, OrderID, PayID, Amount, Status, Payment_time, PayerID)
VALUES (1, 1, 1, 10.00, "completed", "18/3/16 18:35", 1),
(2, 2, 2, 20.00, "pending", "18/3/17 18:35", 2),
(3, 3, 3, 50.00, "completed", "18/3/18 18:35", 3),
(4, 4, 4, 900.00, "completed", "18/3/19 18:35", 4),
(5, 5, 5, 2700.00, "completed", "18/3/20 18:35", 5),
(6, 6, 6, 120.00, "completed", "18/3/21 18:35", 6),
(7, 7, 7, 1500.00, "completed", "18/3/22 18:35", 7),
(8, 8, 8, 2880.00, "pending", "18/3/23 18:35", 8),
(9, 9, 9, 880.00, "completed", "18/3/24 18:35", 9),
(10, 10, 10, 160.00, "pending", "18/3/25 18:35", 10);
INSERT INTO Payment_Method (PayID, BuyerID, Card_number, Hold_name)
values (1, 1, 472409009120, "Ziqian"),
(2, 2, 472409009121, "Mingyi"),
(3, 3, 472409009122, "Kairui"),
(4, 4, 472409009123, "Robbert"),
(5, 5, 472409009124, "Zhuoran"),
(6, 6, 472409009125, "Lulu"),
(7, 7, 472409009126, "Sam"),
(8, 8, 472409009127, "Mike"),
(9, 9, 472409009128, "Allen"),
(10, 10, 472409009129, "Amber");
/*Queries
For Buyer that has used all the payment method under the buyer's name
*/
SELECT B.BuyerID, B.Username
FROM Buyer B
WHERE NOT EXISTS (SELECT PayID FROM Payment_Method PM WHERE PM.BuyerID = B.BuyerID EXCEPT
SELECT P.PayID FROM Payment P
WHERE P.PayerID = B.BuyerID)
/*Queries
For Buyer that has not used all the payment method under the buyer's name(Noncorrelated)
*/
SELECT B.BuyerID, B.Username
FROM Buyer B
WHERE EXISTS (SELECT PayID FROM Payment_Method PM WHERE PM.BuyerID = B.BuyerID EXCEPT
SELECT P.PayID FROM Payment P)
/*Queries
Select payment method has not been used (Noncorrelated)
*/
SELECT PayID FROM Payment_Method PM EXCEPT
SELECT P.PayID FROM Payment P
/*Queries
Select product that has been ordered by customer 1
*/
SELECT ProductID, StoreID FROM 'Transaction' WHERE OrderID IN (SELECT OrderID FROM 'ORDER' WHERE BuyerID = 1)
/*Queries
Select Transactions that has been shipped
*/
SELECT TransID FROM 'Transaction' T WHERE OrderID IN (Select OrderID FROM 'Order' WHERE BuyerID = 1 INTERSECT SELECT OrderID FROM Shipment S WHERE S.OrderID = T.OrderID)
| true |
a1796dc75b7fc2c91a1df9f8de30421d4de65b23 | SQL | da99/megauni | /src/megauni/Conversation/postgresql/020.table.conversation.sql | UTF-8 | 249 | 2.796875 | 3 | [
"MIT"
] | permissive |
SET ROLE db_owner;
CREATE TABLE "conversation" (
id BIGSERIAL PRIMARY KEY,
author_id BIGINT NOT NULL, -- screen name id
title VARCHAR(180),
body TEXT,
created_at timestamptz NOT NULL DEFAULT NOW()
);
COMMIT;
| true |
8d92f137cf83b402695cebf82a08a674a6b0293c | SQL | Blackset/Cdi18 | /cdi /exo sql/SQLQuery12.sql | ISO-8859-1 | 136 | 2.71875 | 3 | [] | no_license | select nom_employ, pn_employ,date_embauche
from employ
where datediff(dd,date_embauche, cast ('24/03/1991' as datetime)) < 0
| true |
1daa6728f29500353eb401593d6b9f356e601dbb | SQL | 996949805/BCGit | /Application/fundsapp/Controller/test.sql | UTF-8 | 2,191 | 3.953125 | 4 | [] | no_license | select ft.category,ft.titlename,a1.titleid,
(a1.sum_month+a2.sum_month+a3.sum_month+a4.sum_month) sum_month,
a1.sum_month a1_sum_month,
a2.sum_month a2_sum_month,
a3.sum_month a3_sum_month,
a4.sum_month a4_sum_month,
(a1.day25+a2.day25+a3.day25+a4.day25) sum_yestoday,
a1.day25 a1_yestoday,
a2.day25 a2_yestoday,
a3.day25 a3_yestoday,
a4.day25 a4_yestoday,
(a1.day0+a2.day0+a3.day0+a4.day0) sum_day0,
a1.day0 a1_day0,
a2.day0 a2_day0,
a3.day0 a3_day0,
a4.day0 a4_day0,
(a1.day99+a2.day99+a3.day99+a4.day99) sum_day99,
a1.day99 a1_day99,
a2.day99 a2_day99,
a3.day99 a3_day99,
a4.day99 a4_day99,
(y1.s+y2.s+y3.s+y4.s) sum_y,
y1.s y1,
y2.s y2,
y3.s y3,
y4.s y4
from (select titleid,sum_month,day0,day99,day25 from fundsdata where yearmonth='2017-04' and subcompany=1) a1, -- 每月的 月结、计划数、去年同期、昨天
(select titleid,sum_month,day0,day99,day25 from fundsdata where yearmonth='2017-04' and subcompany=2) a2,
(select titleid,sum_month,day0,day99,day25 from fundsdata where yearmonth='2017-04' and subcompany=3) a3,
(select titleid,sum_month,day0,day99,day25 from fundsdata where yearmonth='2017-04' and subcompany=4) a4,
(select titleid,sum(sum_month) s from fundsdata where substring(yearmonth,1,4)='2017' and subcompany=1 group by titleid) y1, -- 年合计
(select titleid,sum(sum_month) s from fundsdata where substring(yearmonth,1,4)='2017' and subcompany=2 group by titleid) y2,
(select titleid,sum(sum_month) s from fundsdata where substring(yearmonth,1,4)='2017' and subcompany=3 group by titleid) y3,
(select titleid,sum(sum_month) s from fundsdata where substring(yearmonth,1,4)='2017' and subcompany=4 group by titleid) y4,
fundstitle ft
where a1.titleid=a2.titleid
and a2.titleid=a3.titleid
and a3.titleid=a4.titleid
and a1.titleid=ft.id
and y1.titleid=a1.titleid
and y2.titleid=a1.titleid
and y3.titleid=a1.titleid
and y4.titleid=a1.titleid
order by ft.showorder;
| true |
01625a871c7f690c17f6c7cbcd43a0b6cc0ab12d | SQL | rtrice1/coplink | /db/create_podata_stored_proc.sql | UTF-8 | 4,960 | 3.640625 | 4 | [] | no_license | Drop Procedure if exists GetPodataCriticalSpareDiffs;
DELIMITER //
CREATE PROCEDURE GetPodataCriticalSpareDiffs()
BEGIN
drop table if exists podata_critical_spares_tmp;
/* Get a current view of what's going on */
CREATE TEMPORARY TABLE podata_critical_spares_tmp (cop_id varchar(30) default 'noid')
select
(CONCAT(REPLACE(po.num, 'AAL-', ' ') , ':' , poitem.polineitem)) as podata_id,
po.num,
poitem.polineitem,
poitem.partnum,
serial.serialnum,
ssaisrid.info ssaisrid,
poitem.revlevel as revision,
poitem.description,
poitem.qtytofulfill,
REPLACE(REPLACE(poitem.note, CHAR(13), ' '),CHAR(10), ' ') as polineitemnote,
DATE_FORMAT(rcptitem.datereceived,'%m/%d/%Y') as DateReceived,
REPLACE(REPLACE(memo.memo, CHAR(13), ' '), CHAR(10), ' ') as LastMemoEntry,
pos.name as Status,
requestingsite.info as requestingsite,
(case iscritical.info when 1 THEN 'Y' ELSE 'N' end) as IsCriticalSpare,
pocategory.info as POCategory
from bha.po po
inner join bha.poitem poitem on poitem.poid = po.id
inner join bha.poitemtype poitemtype on poitemtype.id = poitem.typeid
left join bha.part part on poitem.partid = part.id
left join bha.customvarchar ssaisrid on ssaisrid.customfieldid = 36 and ssaisrid.recordid = part.id
left join bha.customvarchar failurerpt on failurerpt.customfieldid = 26 and failurerpt.recordid = po.id
left join bha.customset dpas on dpas.customfieldid = 6 and dpas.recordid = po.id
left join bha.pickitem on pickitem.partid = part.id and pickitem.poitemid = poitem.id and pickitem.ordertypeid = 10
left join bha.trackinginfo ti on ti.parttrackingid = 4 and ti.tableid = -1515431424 and ti.recordid = pickitem.id
inner join bha.trackinginfosn serial on serial.trackinginfoid = ti.id and serial.parttrackingid = 4
left join bha.customfield cf on upper(cf.name) LIKE upper('%PO%Contract%Type%') and cf.customfieldtypeid = 7 and cf.tableid = 397076832
left join bha.customset contracttype on contracttype.customfieldid = cf.id and contracttype.recordid = po.id
left join bha.postatus pos on pos.id = po.statusid
left join bha.memo memo on memo.id =
(
SELECT memo.id
FROM bha.memo memo
WHERE memo.recordid = po.id AND memo.tableid = 397076832
ORDER BY memo.id desc
LIMIT 1
)
left join bha.customset requestingsite on requestingsite.customfieldid = 29 and requestingsite.recordid = po.id
left join bha.custominteger iscritical on iscritical.customfieldid = 32 and iscritical.recordid = poitem.partid
left join bha.customset pocategory on pocategory.customfieldid = 31 and pocategory.recordid = po.id
left join bha.receiptitem rcptitem on rcptitem.poitemid = poitem.id
where iscritical.info = 1
and pos.name not in ('Void')
order by po.num, poitem.polineitem, pos.name;
update podata_critical_spares_tmp set DateReceived = 'None' where DateReceived is null;
truncate podata_critical_spares_changes;
insert into podata_critical_spares_changes
select 'add' as operation, a.*
from podata_critical_spares_tmp a
where a.podata_id not in
(select b.podata_id from podata_critical_spares b);
insert into podata_critical_spares_changes
select 'delete' as operation, a.*
from podata_critical_spares a
where a.podata_id not in
(select b.podata_id from podata_critical_spares_tmp b);
/* This complicated query brought to you by MySQL because they don't support EXCEPT */
update podata_critical_spares_tmp a
set a.cop_id =
(select b.cop_id from podata_critical_spares b where b.podata_id = a.podata_id);
insert into podata_critical_spares_changes
select 'update' as operation, a.*
from podata_critical_spares_tmp a
left join podata_critical_spares b
on
a.podata_id = b.podata_id and
a.num = b.num and
a.polineitem = b.polineitem and
a.partnum = b.partnum and
a.serialnum = b.serialnum and
a.ssaisrid = b.ssaisrid and
a.revision = b.revision and
a.description = b.description and
a.qtytofulfill = b.qtytofulfill and
a.polineitemnote = b.polineitemnote and
a.DateReceived = b.DateReceived and
a.LastMemoEntry = b.LastMemoEntry and
a.Status = b.Status and
a.requestingsite = b.requestingsite and
a.IsCriticalSpare = b.IsCriticalSpare and
a.POCategory = b.POCategory
where b.podata_id is null and
a.podata_id not in (select podata_id from
podata_critical_spares_changes where operation = 'add');
END //
DELIMITER ;
| true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.