Presentasi sedang didownload. Silahkan tunggu

Presentasi sedang didownload. Silahkan tunggu

1 H. SUMIJAN, Ir, M.Sc, MCP, OCP STAF PENGAJAR Universitas Putra Indonesia “YPTK”

Presentasi serupa


Presentasi berjudul: "1 H. SUMIJAN, Ir, M.Sc, MCP, OCP STAF PENGAJAR Universitas Putra Indonesia “YPTK”"— Transcript presentasi:

1 1 H. SUMIJAN, Ir, M.Sc, MCP, OCP STAF PENGAJAR Universitas Putra Indonesia “YPTK”

2 2 Create Table Tfakultas ( Kode_f Char(16) NOT NULL PRIMARY Key, Nama_f Varchar2(100), Nama_PS char(20), Status char(45), NoSK char(35) ); Create Table Tmhs ( Nobp Char(16) NOT NULL PRIMARY Key, Nama Varchar2(100), Kelas char(15), Kode_f char(3) References Tfakultas(Kode_f) );

3 3 Create Table Tmtk ( Kode_MK Char(10) NOT NULL PRIMARY Key, Nama_MK Varchar2(100), Sks number(2), Prasyarat1 char(10), Prasyarat2 char(10), Prasyarat3 char(10) ); Create Table tNilai ( Kode_MK Char(10) References tmtk(kode_mk), Nobp Char(16) References tmhs(nobp), Nilai_KUIS number(5,2), Nilai_PR number(5,2), Nilai_UTS number(5,2), Nilai_UAS number(5,2), constraint pk_nilai PRIMARY KEY (kode_mk, Nobp) );

4 4 Insert into Tmtk values ('KKKI53001','Apl. DBServer',2,NULL,NULL,NULL); Insert into Tmtk values ('KKKI52002','Perbankan',2,NULL,NULL,NULL); Insert into Tmtk values ('KKKI53011','Multiuser',2,NULL,NULL,NULL); Insert into Tmtk values ('KKKI53012','Mnj. Sains',2,NULL,NULL,NULL); Insert into Tmtk values ('KKKI52005','Peng. Sistem Informasi',2,NULL,NULL,NULL); Insert into Tmtk values ('KKKI52006','Prak. Sistem Operasi Jaringan',2,NULL,NULL,NULL); Insert into Tmtk values ('KKKI53007','Teknik Kompilasi',2,NULL,NULL,NULL); Insert into tfakultas values ('261','Ilmu Komputer','Sistem Informasi','Terakreditasi','001/BAN-PT/S1/SK/2009'); Insert into tfakultas values ('262','Ilmu Komputer','Sistem Komputer','Terakreditasi','056/BAN-PT/S1/SK/2006'); Insert into tfakultas values ('260','Ilmu Komputer','Mnj. Informatika','Terakreditasi','089/BAN-PT/D3/SK/2006'); Insert into tfakultas values ('263','Ilmu Komputer','Teknik Informatika','Terdaftar','-'); Insert into tfakultas values ('511','Ekonomi','S1-Akuntansi', 'Terakreditasi','056/BAN-PT/S1/SK/2006'); Insert into tfakultas values ('531','Ekonomi','S1-Manajemen‘,'Terakreditasi','089/BAN-PT/D3/SK/2006'); Insert into tfakultas values ('751','Psikologi','Psikologi','Terakreditasi','089/BAN-PT/S1/SK/2009'); Insert into tfakultas values ('425','Teknologi Industri','Teknik Industri','Terdaftar','-'); Insert into tfakultas values ('433','Sipil Dan Perencanaan','Teknik Sipil,'Terdaftar','-'); Insert into tfakultas values ('911','Desain Komunikasi Visual','Desain Komunikasi Visual','Terdaftar','-'); Insert into tfakultas values ('811','Pascasarjana','S2-Magister Manajemen','Terakreditasi','089/BAN-PT/S2/SK/2008'); Insert into tfakultas values ('812','Pascasarjana','S2-Magister Komputer','Terakreditasi','089/BAN-PT/S2/SK/2008');

5 5 Insert into tmhs values (' ','Widya','4SI-6','261'); Insert into tmhs values (' ','Atika','4SI-6','261'); Insert into tmhs values (' ','Danny','4SI-6','261'); Insert into tmhs values (' ','Debie','4SI-6','261'); Insert into tmhs values (' ','Thia','4SI-6','261'); Insert into tmhs values (' ','Susy','4SI-6','261'); Insert into tmhs values (' ','Egil','4SI-6','261');

6 6 Insert into tnilai values ('KKKI53001',' ',80,75,60,60); Insert into tnilai values ('KKKI52002',' ',80,85,65,75); Insert into tnilai values ('KKKI53011',' ',70,55,70,80); Insert into tnilai values ('KKKI53012',' ',80,65,80,90); Insert into tnilai values ('KKKI52005',' ',90,75,90,60); Insert into tnilai values ('KKKI52006',' ',60,65,80,70); Insert into tnilai values ('KKKI53001',' ',80,75,60,60); Insert into tnilai values ('KKKI52002',' ',80,85,65,75); Insert into tnilai values ('KKKI53011',' ',70,55,70,80); Insert into tnilai values ('KKKI53012',' ',80,65,80,90); Insert into tnilai values ('KKKI52005',' ',90,75,90,60); Insert into tnilai values ('KKKI52006',' ',60,65,80,70); Insert into tnilai values ('KKKI53007',' ',70,55,90,80); Insert into tnilai values ('KKKI53001',' ',80,75,60,60); Insert into tnilai values ('KKKI52002',' ',80,85,65,75); Insert into tnilai values ('KKKI53011',' ',70,55,70,80); Insert into tnilai values ('KKKI53012',' ',80,65,80,90); Insert into tnilai values ('KKKI52005',' ',90,75,90,60); Insert into tnilai values ('KKKI52006',' ',60,65,80,70); Insert into tnilai values ('KKKI53007',' ',70,55,90,80); Insert into tnilai values ('KKKI53001',' ',80,75,60,60);

7 7 Insert into tnilai values ('KKKI52002',' ',80,85,65,75); Insert into tnilai values ('KKKI53011',' ',70,55,70,80); Insert into tnilai values ('KKKI53012',' ',80,65,80,90); Insert into tnilai values ('KKKI52005',' ',90,75,90,60); Insert into tnilai values ('KKKI52006',' ',60,65,80,70); Insert into tnilai values ('KKKI53007',' ',70,55,90,80); Insert into tnilai values ('KKKI53001',' ',80,75,60,60); Insert into tnilai values ('KKKI52002',' ',80,85,65,75); Insert into tnilai values ('KKKI53011',' ',70,55,70,80); Insert into tnilai values ('KKKI53012',' ',80,65,80,90); Insert into tnilai values ('KKKI52005',' ',90,75,90,60); Insert into tnilai values ('KKKI52006',' ',60,65,80,70); Insert into tnilai values ('KKKI53007',' ',70,55,90,80); Insert into tnilai values ('KKKI53001',' ',80,75,60,60); Insert into tnilai values ('KKKI52002',' ',80,85,65,75); Insert into tnilai values ('KKKI53011',' ',70,55,70,80); Insert into tnilai values ('KKKI53012',' ',80,65,80,90); Insert into tnilai values ('KKKI52005',' ',90,75,90,60); Insert into tnilai values ('KKKI52006',' ',60,65,80,70); Insert into tnilai values ('KKKI53007',' ',70,55,90,80); commit;

8 8 Limiting the Rows Selected  Restrict the rows returned by using the WHERE clause.  The where clause follows the FROM clause. SELECT* | {[DISTINCT] column | expression [alias], …} FROMtable [WHERE condition(s)];

9 9 Using the WHERE Clause SELECTKode_f, Nama_f, Nama_PS, substr(Kode_f,1,2) as Kode_Fak FROMtfakultas WHERE substr(Kode_f,1,2)=26;

10 10 Character Strings and Dates  Character strings and date values are enclosed in single quotation marks.  Character values are case sensitive, and date values are format sensitive.  The default date format is DD-MON-RR. SELECTKode_f, Nama_f, Nama_PS, substr(Kode_f,1,2) as Kode_Fakultas FROMtfakultas WHERE Nama_F = 'Ekonomi';

11 11 Comparison Conditions OperatorMeaning =Equal to >Greater than >=Greater than or equal to Not equal to SELECT* FROMtnilai where nilai_UAS >=90

12 12 Other Comparison Conditions OperatorMeaning BETWEEN … AND … Between two values (inclusive) INMatch any of a list of values LIKEMatch a character pattern IS [NOT] NULLIs a null value Concatenation operator (||)

13 13 Using the BETWEEN Condition SELECT* FROMtnilai where nilai_UAS between 80 and 90 Use the BETWEEN condition to display rows based on a range of values. Lower limitUpper limit

14 14 Using the IN Condition SELECT* FROMtnilai where nilai_UAS in(70,90) Use the IN membership condition to test for values in a list.

15 15 Using the LIKE Condition SELECT Nama_PS FROMtfakultas WHERE Nama_Ps LIKE 'S%'; Use the LIKE condition to perform wildcard searches of valid search string values. Search conditions can contain either literal characters or numbers. - % denotes zero or many characters. - _ (underscore) denotes one character.

16 16 Using the LIKE Condition SELECT Nama_PS FROMtfakultas WHERE Nama_Ps LIKE 'S%'; You can combine pattern-matching characters. You can use the ESCAPE identifier to search for the actual % and _ symbols. SELECT Nama_F, Nama_PS FROMtfakultas WHERE Nama_Ps LIKE 'S%' ESCAPE '\';

17 17

18 18 Using the NULL Condition SELECT * FROMtmhs WHERE Kelas is NULL Test for nulls with the IS NULL operator.

19 19 Logical Conditions OperatorMeaning ANDReturns TRUE if both component conditions are true ORReturns TRUE if either component condition is true NOTReturns TRUE if the following condition is false ANDTRUEFALSENULL TRUE FLASENULL FALSE NULL FLASENULL AND Truth Table ORTRUEFALSENULL TRUE FALSETRUEFALSENULL TRUENULL OR Truth Table

20 20 Using the AND Operator SELECT Nama_F, Nama_PS FROMtfakultas WHERE Nama_Ps LIKE 'S%' and substr(kode_f,1,2)=26 AND requires both conditions to be true.

21 21 Using the OR Operator SELECT* FROMtnilai where nilai_UAS >=80 and Kode_MK like '%12%' OR requires either condition to be true. 8 rows selected

22 22 Using the NOT Operator SELECT * FROMtnilai where nilai_UAS >=80 and Kode_MK not in ('KKKI52012','KKKI53012');

23 23 Rules of Precedence Order EvaluatedOperator 1Arithmetic Operators 2Concatenation Operator 3Comparisons conditions 4IS [NOT] NULL, LIKE, [NOT] IN 5[NOT] BETWEEN 6NOT logical condition 7AND logical condition 8OR logical condition Override rules of precedence by using parentheses.

24 24 The CREATE TABLE Statement CREATE TABLE table (column datatype [DEFAULT expr], …); Example: CREATE TABLE dept (dept_no number(3), dept_name varchar2(15), location varchar2(10)); Table created. You must have: - CREATE TABLE privilege - A storage area

25 25 Data Types Description VARCHAR2(size)Variable-length character data CHAR(size)Fixed-length character data NUMBER(p,s)Variable length numeric data DATEDate and time values LONGVariable-length character data up to 2 gigabytes CLOBCharacter data up to 4 gigabytes RAW and LONG RAWRaw binary data BLOBBinary data up to 4 gigabytes BFILEBinary data stored in an external file; up to 4 gigabytes ROWIDA 64 base number system representing the unique address of a row in its table

26 26 The ALTER TABLE Statement Use the ALTER TABLE statement to: Add a new column Modify an existing column Define a default value for the new column Drop a column

27 27 The ALTER TABLE Statement ALTER TABLE table ADD(column datatype [DEFAULT expr], …); Example: ALTER TABLE dept ADD(dept_id number(3)); Table altered.

28 28 The ALTER TABLE Statement ALTER TABLE table MODIFY(column datatype [DEFAULT expr], …); Example: ALTER TABLE dept MODIFY(dept_id number(3)); Table altered. ALTER TABLE table DROP(column); Example: ALTER TABLE dept DROP(dept_id); Table altered.

29 29 Dropping a TABLE DROP TABLE dept; Table dropped. All data and structure in the table is deleted. Any pending transactions are committed. All indexes are dropped You cannot roll back the DROP TABLE statement.

30 30 Data Manipulation Language A DML statement is executed when you: - Add new rows to a table - Modify existing rows in a table - Remove existing rows from a table A transaction consists of a collection of DML statements that form a logical unit of work

31 31 The INSERT Statement INSERT INTO table [(column_1, column_2, …)] VALUES (value1, value2, …); Add new rows to a table by using the INSERT statement. Only one row is inserted at a time with this syntax. Example: INSERT INTO dept (dept_no, dept_name, location) VALUES (001, ‘Marketing’, ‘Padang’);

32 32 The INSERT Statement Insert from another table: INSERT INTO dept (dept_no, dept_name, location) SELECT department_id, department_name, area FROM department WHERE department_id = ‘101’; Do not use VALUES clause Match the number of columns in the INSERT clause to those in the subquery.

33 33 The UPDATE Statement UPDATE table SET column = value [, column = value, …] [WHERE condition]; Modify existing rows in a table by using the UPDATE statement. Update more than one row at a time, if required. Example: UPDATE dept SET dept_name = ‘Production’ WHERE dept_name = ‘Marketing’;

34 34 The DELETE Statement DELETE [FROM] table [WHERE condition]; Remove existing rows from a table by using the DELETE statement. Specific rows are deleted if you specify the WHERE clause. Example: DELETE FROM dept WHERE dept_name = ‘Marketing’; All rows are deleted if you omit the WHERE clause. Example: DELETE FROM dept;

35 35 The DATE Data Type TO_CHAR(date, ‘format_model’); Example: SELECT employee_id, TO_CHAR(hire_date, ‘MM/YY’) Month_Hired FROM employees WHERE last_name = ‘Higgins’; Use TO_CHAR function to display dates. EMPLOYEE_IDMONTH_HIRED 20506/94

36 36 Elements of the DATE Format Model YYTwo-digit value for year YYYYFull year in numbers YEARYear spelled out MMTwo-digit value for month MONTHFull name for the month MONThree-letter abbreviation of the month DYThree-letter abbreviation of the day of the week DAYFull name of the day of the week DDNumeric day of the week

37 37 The DATE Data Type TO_DATE(char, ‘format_model’); Example: INSERT INTO employees (hire_date) VALUES (TO_DATE(’16/05/2005’, ‘DD/MM/YY’)); Use TO_DATE function to convert a character string to a date format.

38 38 Joining Tables SELECTtable1.column, table2.column FROMtable1, table2 WHEREtable1.column1 = table2.column2; Use a join to query data from more than one table. Write the join condition in the WHERE clause. Prefix the column name with the table name when the same column name appears in more than one table.

39 39 Retrieving Records with Equijoins SELECT employees.employee_id, employees.last_name, employees.department_id, departments.department_id, departments.location_id FROMemployees, departments WHEREemployees.department_id = departments.department_id; EMPLOYEE_IDLAST_NAMEDEPARTMENT_ID LOCATION_ID 200Whalen Hartstein Fay …..

40 40 Additional Search Conditions SELECT employees.last_name, employees.department_id, department_name FROMemployees, departments WHEREemployees.department_id = departments.department_id ANDlast_name = ‘Matos’; LAST_NAMEDEPARTMENT_IDDEPARTMENT_NAME Matos50Shipping

41 41 Join with Aliases SELECT e.last_name, e.department_id, d.department_name FROMemployees e, departments d WHEREe.department_id = d.department_id ANDe.last_name = ‘Matos’; LAST_NAMEDEPARTMENT_IDDEPARTMENT_NAME Matos50Shipping

42 42 Creating a Table using a Subquery CREATE TABLE dept80 AS SELECT employee_id, last_name, salary*12 ann_sal, hire_date FROMemployees WHEREdepartment_id = 80; Table created. NameNull?Type EMPLOYEE_IDNUMBER(6) LAST_NAMENOT NULLVARCHAR2(25) ANN_SALNUMBER HIRE_DATENOT NULLDATE

43 43 Constraints Constraints enforce rules at the table level. Constraints prevent the deletion of a table if there are dependencies. The following constraint types are valid: - NOT NULL – a column cannot contain a null value - UNIQUE – values must be unique for all rows - PRIMARY KEY – uniquely identifies each row - FOREIGN KEY – establishes a foreign key in relation - CHECK – a condition must be true

44 44 Defining Constraints column [CONSTRAINT constraint_name] constraint_type; Column constraint level Table constraint level Column, … [CONSTRAINT constraint_name] constraint_type (column, …),

45 45 The NOT NULL Constraints CREATE TABLE employees ( employee_idNUMBER(6), last_nameVARCHAR2(25) NOT NULL, salaryNUMBER(8,2), commission_pctNUMBER(2,2), hire_dateDATE CONSTRAINT emp_hire_date_nn NOT NULL, … Defined at the column level:

46 46 The UNIQUE Constraints CREATE TABLE employees ( employee_idNUMBER(6), last_nameVARCHAR2(25) NOT NULL, salaryNUMBER(8,2), commission_pctNUMBER(2,2), hire_dateDATE NOT NULL, … CONSTRAINT emp_ _uk UNIQUE( )); Defined at either the table level or the column level:

47 47 The PRIMARY KEY Constraints CREATE TABLE departments ( department_idNUMBER(4), department_nameVARCHAR2(30) CONSTRAINT dept_name_nn NOT NULL, manager_idNUMBER(6), location_idNUMBER(4), CONSTRAINT dept_id_pk PRIMARY KEY (department_id)); Defined at either the table level or the column level:

48 48 The FOREIGN KEY Constraints CREATE TABLE employees ( employee_idNUMBER(6), last_nameVARCHAR2(25) NOT NULL, salaryNUMBER(8,2), commission_pctNUMBER(2,2), hire_dateDATE NOT NULL, … department_idNUMBER(4), CONSTRAINT emp_dept_fk FOREIGN KEY (department_id) REFERENCES departments(department_id), CONSTRAINT emp_ _uk UNIQUE( )); Defined at either the table level or the column level:

49 NobpNm_MhsKelasKode_f 001Acong4SI Sitorus4SI Joko4SK Aziz Gagak4SK-2262 Kode_fNm_PS 261Sistem Informasi 262Sistem Komputer 260Mnj. Informatika 263Teknik Informatika Tabel Fakultas Tabel Mahasiswa dihubungkan dengan tabel Fakultas melalui kode_f, tabel Mahasiswa dg tabel Nilai melalui Nobp dan tabel Matakuliah dg tabel Nilai melalui Kode_MK Tabel Mahasiswa NobpKode_MKNilai_PrNilai_KuisNilai_UTSNilai_UAS 001KKKI KKKI KKKI KKKI KKKI KKKI Kd_MKNm_MK KKKI52001Apl. Db Server KKKI53002Perbankan KKKI53003Mnj. Sains Tabel Matakuliah Tabel Nilai Contoh Database Universitas

50 Kd_BrgNm_BrgHarga_BeliKd_Pemasok 100Pepsodent Lifeboy Shampo Clear Shampo Pantene Kd_PemasokNm_Pemasok 10Godilever 20Century 30Mitra Jaya 40Jaya Bersama Tabel Pemasok Tabel barang dihubungkan dengan tabel pemasok melalui kode_pemasok, Tabel Barang dg Tabel Transaksi_Jual melalui Kd_Brg dan Tabel Pelanggan dg Tabel Transaksi_Jual melalui Kd_Plg Tabel Barang Kd_BrgKd_PlgNo_FactTgl_TransJumlahHarga_Jual /09/ /09/ /09/ /09/ /09/ /09/ Kd_PlgNm_Plg 220Acong 221Sitorus 222Joko Tabel Pelanggan Tabel Transaksi_Jual Contoh Database Penjualan

51 Buat Query sbb : select * from mahasiswa, matakuliah, nilai where mahasiswa.npm=nilai.npm and matakuliah.Kode_MtK=nilai.Kode_MtK; select NPM, t1.Nama_Mhs, t2.Kode_MTK, Nama_MTK, Sks, NA from mahasiswa t1, matakuliah t2, nilai t3 where t1.npm=t3.npm and t2.Kode_MTK=t3.Kode_MTK; select t1.NPM, Nama_Mhs, t2.Kode_MTK, Nama_MTK, Sks, NA from mahasiswa t1, matakuliah t2, nilai t3 where t1.npm=t3.npm and t2.Kode_MTK=t3.Kode_MTK order by t1.NPM;

52 select t1.NPM, Nama_Mhs, t2.Kode_MTK, Nama_MTK, Sks, NA from mahasiswa t1, matakuliah t2, nilai t3 where t1.npm=t3.npm and t2.Kode_MTK=t3.Kode_MTK and t1.NPM in (' '); select t1.NPM, Nama_Mhs, t2.Kode_MTK, Nama_MTK, Sks, NA from mahasiswa t1, matakuliah t2, nilai t3 where t1.npm=t3.npm and t2.Kode_MTK=t3.Kode_MTK and t1.NPM between ' ' and ' '; select t1.NPM, Nama_Mhs, t2.Kode_MTK, Nama_MTK, Sks, NA from mahasiswa t1, matakuliah t2, nilai t3 where t1.npm=t3.npm and t2.Kode_MTK=t3.Kode_MTK and t1.NPM >=' ' Cont. Buat Query sbb :

53 53 FAKULTAS Kode_F Nm_Fakultas MATAKULIAH Kode_mtk Nama_Mtk Sks Kode_f MAHASISWA Nobp Nama Kode_f Pin NILAI NPM Kode_Mtk NILAi_Kuis Nilai_Pr Nilai_UTS Nilai_UAS

54 54 select t1.nobp, nama, t2.kode_mk,nama_mk,sks,nilai_kuis, nilai_pr, nilai_uts, nilai_uas, (nilai_kuis+nilai_pr+nilai_uts+nilai_uas)/4 as Ratarata from tmhs t1, tmtk t2, tnilai t3 where t1.nobp=t3.nobp and t2.kode_mk=t3.kode_mk and t1.nobp in (' ',' '); 1. Tampilkan nobp, nama, kode_mk,nama_mk,sks,nilai_kuis, nilai_pr, nilai_uts, nilai_uas, dan rata-rata =nilai_kuis+nilai_pr+nilai_uts+nilai_uas)/4 Ratarata dari tabel tmhs t1, tmtk t2, tnilai t3 untuk Nonp dan

55 55 Create view contohvw as select t1.nobp, nama, t2.kode_mk,nama_mk,sks,nilai_kuis, nilai_pr, nilai_uts, nilai_uas, (0.10*nilai_kuis)+(0.20*nilai_pr)+(0.30*nilai_uts)+(0.40*nilai_uas) as Ratarata from tmhs t1, tmtk t2, tnilai t3 where t1.nobp=t3.nobp and t2.kode_mk=t3.kode_mk and t1.nobp in (' ',' '); 2. Tampilkan nobp, nama, t2.kode_mk,nama_mk,sks,nilai_kuis, nilai_pr, nilai_uts, nilai_uas, ratarata= (10%*nilai_kuis) + (20%*nilai_pr) + (30%*nilai_uts) + (40%*nilai_uas) dari table tmhs, tmtk dan tnilai untuk Nobp dan

56 56 Create view contohvw select t1.nobp, nama, t2.kode_mk,nama_mk,sks,nilai_kuis, nilai_pr, nilai_uts, nilai_uas, (0.10*nilai_kuis)+(0.20*nilai_pr)+(0.30*nilai_uts)+(0.40*nilai_uas) as Ratarata from tmhs t1, tmtk t2, tnilai t3 where t1.nobp=t3.nobp and t2.kode_mk=t3.kode_mk and t2.nama_mk like '%an%' 3. Tampilkan nobp, nama, t2.kode_mk,nama_mk,sks,nilai_kuis, nilai_pr, nilai_uts, nilai_uas, ratarata= (10%*nilai_kuis) + (20%*nilai_pr) + (30%*nilai_uts) + (40%*nilai_uas) dari table tmhs, tmtk dan tnilai Untuk nama_mk yang mengandung karakter ‘an’

57 57

58 58 Create view contohvw select t2.kd_cust,nama, t1.kd_brg, nama_brg,tglj,t1.harga,jml, t1.harga*jml as TotalHarga, (0.05*t1.harga*jml) as Discount, (t1.harga*jml)-(0.05*t1.harga*jml) as TotalBersih from barang t1, customer t2, transaksi t3 where t1.kd_brg=t3.kd_brg and t2.kd_cust=t3.kd_cust; 1. Tampilkan kd_k,nama, kd_m, jenis,tglj, jml, harga, TotalHarga= jml*t1.harga, discount=10%*jml*harga, TotalBersih=TotalHarga- Discount dari table Mobil, konsumen, dan Jual

59 59 Create view contohvw select t2.kd_cust,nama, t1.kd_brg, nama_brg,tglj,t1.harga,jml, t1.harga*jml as TotalHarga, (0.05*t1.harga*jml) as Discount, (t1.harga*jml)-(0.05*t1.harga*jml) as TotalBersih from barang t1, customer t2, transaksi t3 where t1.kd_brg=t3.kd_brg and t2.kd_cust=t3.kd_cust and t2.kd_cust in ('K0002','K0005'); 2. Tampilkan kd_k,nama, kd_m, jenis,tglj, jml, harga, TotalHarga= jml*t1.harga, discount=10%*jml*harga, TotalBersih=TotalHarga-Discount dari table Mobil, konsumen, dan Jual untuk Konsumen 'K0001‘ dan 'K0005'

60 60 Create view contohvw select t2.kd_cust,nama, t1.kd_brg, nama_brg,tglj,t1.harga,jml, t1.harga*jml as TotalHarga, (0.05*t1.harga*jml) as Discount, (t1.harga*jml)-(0.05*t1.harga*jml) as TotalBersih from barang t1, customer t2, transaksi t3 where t1.kd_brg=t3.kd_brg and t2.kd_cust=t3.kd_cust and tglj between '02-mar-05' and '05-dec-05' order by tglj; 3. Tampilkan kd_k,nama, kd_m, jenis,tglj, jml, harga, TotalHarga= jml*t1.harga, discount=10%*jml*harga, TotalBersih=TotalHarga-Discount dari table Mobil, konsumen, dan Jual untuk transaksi penjualan tanggal '02- mar-05' sampai dengan '05-dec-05' dan urutkan berdasarkan tanggal jual

61 61

62 62 select t2.kd_k,nama, t1.kd_m, jenis,tglj, jml, t1.harga, jml*t1.harga as TotalHarga, (0.10*jml*t1.harga) as Discount, (jml*t1.harga)-(0.10*jml*t1.harga) as TotalBersih from Mobil t1, konsumen t2, Jual t3 where t1.kd_m=t3.kd_m and t2.kd_k=t3.kd_k; 1. Tampilkan kd_k,nama, kd_m, jenis,tglj, jml, harga, TotalHarga= jml*t1.harga, discount=10%*jml*harga, TotalBersih=TotalHarga- Discount dari table Mobil, konsumen, dan Jual

63 63 select t2.kd_k,nama, t1.kd_m, jenis,tglj, jml, t1.harga, jml*t1.harga as TotalHarga, (0.10*jml*t1.harga) as Discount, (jml*t1.harga)-(0.10*jml*t1.harga) as TotalBersih from Mobil t1, konsumen t2, Jual t3 where t1.kd_m=t3.kd_m and t2.kd_k=t3.kd_k and t3.kd_k in ('K0001','K0005'); 2. Tampilkan kd_k,nama, kd_m, jenis,tglj, jml, harga, TotalHarga= jml*t1.harga, discount=10%*jml*harga, TotalBersih=TotalHarga-Discount dari table Mobil, konsumen, dan Jual untuk Konsumen 'K0001‘ dan 'K0005'

64 64 select t2.kd_k,nama, t1.kd_m, jenis,tglj, jml, t1.harga, jml*t1.harga as TotalHarga, (0.10*jml*t1.harga) as Discount, (jml*t1.harga)-(0.10*jml*t1.harga) as TotalBersih from Mobil t1, konsumen t2, Jual t3 where t1.kd_m=t3.kd_m and t2.kd_k=t3.kd_k and tglj between '02-mar-05' and '05-dec-05' order by tglj; 3. Tampilkan kd_k,nama, kd_m, jenis,tglj, jml, harga, TotalHarga= jml*t1.harga, discount=10%*jml*harga, TotalBersih=TotalHarga-Discount dari table Mobil, konsumen, dan Jual untuk transaksi penjualan tanggal '02-mar-05' sampai dengan '05-dec-05' dan urutkan berdasarkan tanggal jual

65 65

66 66 select t2.kodevcd, judul,t1.kodepenyewa, nama, hargasewa, tglsewa, tglkembali from penyewa t1, vcd t2, peminjaman t3 where t1.kodepenyewa=t3.kodepenyewa and t2.kodevcd=t3.kodevcd and t1.kodepenyewa in ('P-001','P-005') order by t2.kodevcd; 1. Tampilkan kodevcd, judul,t1.kodepenyewa, nama, hargasewa, tglsewa, tglkembali dari table penyewa, vcd, dan peminjaman untuk kdpenyewa 'P-001‘ dan 'P-005') urutkan berdasarkan kodevcd;

67 67 select t2.kodevcd, judul,t1.kodepenyewa, nama, hargasewa, tglsewa from penyewa t1, vcd t2, peminjaman t3 where t1.kodepenyewa=t3.kodepenyewa and t2.kodevcd=t3.kodevcd and tglsewa between '01-Mar-2006' and '01-dec-2006' order by t2.kodevcd; 2. Tampilkan kodevcd, judul,t1.kodepenyewa, nama, hargasewa, tglsewa, tglkembali dari table penyewa, vcd, dan peminjaman untuk tanggal sewa mulai '01-Mar-2006' sampai dengan '01-dec-2006' diurutkan berdasarkan kodevcd;

68 68 select t1.kodepenyewa, nama, sum(hargasewa) as TotalBayar from penyewa t1, vcd t2, peminjaman t3 where t1.kodepenyewa = t3.kodepenyewa and t2.kodevcd=t3.kodevcd and tglsewa between '01- jan-2006' and '01-dec-2006' group by t1.kodepenyewa, nama 3. Tampilkan kodepenyewa, nama, sum(hargasewa) dari table penyewa, vcd, dan peminjaman yang disewa tanggal sewa mulai '01-jan-2006' sampai dengan '01-dec- 2006'

69 69

70 70 Select b.npm, b.nama_mhs, a.kd_b, c.judul, a.tgl_p, a.tgl_k, a.tgl_hrs_k, (a.tgl_k)- (a.tgl_hrs_k) as Lewat, TO_NUMBER((a.tgl_k)-(a.tgl_hrs_k))*1000 as Denda From peminjaman1 a, mahasiswa1 b, buku c Where a.nobp = b.npm AND a.kd_b=c.kd_b and b.npm between ' ' and ' ' order by b.npm 1. Tampilkan npm, b.nama_mhs, a.kd_b, c.judul, a.tgl_p, a.tgl_k, a.tgl_hrs_k, lewat=(a.tgl_k)-(a.tgl_hrs_k), denda setiap hari Rp.1000,- dari tabel peminjaman1, mahasiswa1, dan buku Untuk Npm mulai ' ' sampai dengan ' ' dan urutkan berdasarkan npm

71 71 Select b.npm, b.nama_mhs, a.kd_b, c.judul, a.tgl_p, a.tgl_k, a.tgl_hrs_k, (a.tgl_k)-(a.tgl_hrs_k) as Lewat, TO_NUMBER((a.tgl_k)-(a.tgl_hrs_k))*1000 as Denda From peminjaman1 a, mahasiswa1 b, buku c Where a.nobp = b.npm AND a.kd_b=c.kd_b and tgl_p between '11-may-09' and '13-may-09' and (a.tgl_k)- (a.tgl_hrs_k)>0 order by b.npm 2. Tampilkan npm, b.nama_mhs, a.kd_b, c.judul, a.tgl_p, a.tgl_k, a.tgl_hrs_k, lewat=(a.tgl_k)-(a.tgl_hrs_k), denda setiap hari Rp.1000,- dari tabel peminjaman1, mahasiswa1, dan buku Untuk Tanggal peminjaman mulai '11-may- 09' and '13-may-09' sampai dengan yang terlambat mengembalikan buku dan urutkan berdasarkan npm

72 72 Select b.npm, b.nama_mhs, a.kd_b, c.judul, a.tgl_p, a.tgl_k, a.tgl_hrs_k, (a.tgl_k)- (a.tgl_hrs_k) as Lewat, TO_NUMBER((a.tgl_k)-(a.tgl_hrs_k))*1000 as Denda From peminjaman1 a, mahasiswa1 b, buku c Where a.nobp = b.npm AND a.kd_b=c.kd_b and tgl_p between '14-may-09' and '17-may-09' and (a.tgl_k)- (a.tgl_hrs_k)>=0 order by b.npm 3. Tampilkan npm, b.nama_mhs, a.kd_b, c.judul, a.tgl_p, a.tgl_k, a.tgl_hrs_k, lewat=(a.tgl_k)-(a.tgl_hrs_k), denda setiap hari Rp.1000,- dari tabel peminjaman1, mahasiswa1, dan buku Untuk Tanggal peminjaman mulai '14-may-09' and '17-may-09' sampai dengan yang terlambat mengembalikan buku dan urutkan berdasarkan npm

73 73

74 74 select rute.kd_rute, rute, pesawat.kd_pesawat, pelanggan.kd_plg, nm_plg, harga from rute, pesawat, pelanggan, tiket where pelanggan.kd_plg = tiket.kd_plg and rute.kd_rute=tiket.kd_rute and pesawat.kd_rute=rute.kd_rute and rute.kd_rute between '02' and '03' order by pesawat.kd_pesawat 1. Tampilkan kd_rute, rute, kd_pesawat, kd_plg, nm_plg, harga dari tabel rute, pesawat,pelanggan, dan tiket untuk kd_rute '02' dan '03' urutkan berdasarkan kd_pesawat

75 75 select rute.kd_rute, rute, pesawat.kd_pesawat, pelanggan.kd_plg, nm_plg, harga from rute, pesawat, pelanggan, tiket where pelanggan.kd_plg = tiket.kd_plg and rute.kd_rute=tiket.kd_rute and pesawat.kd_rute=rute.kd_rute and pesawat.kd_pesawat='M-3' order by pesawat.kd_pesawat 2. Tampilkan kd_rute, rute, kd_pesawat, kd_plg, nm_plg, harga dari tabel rute, pesawat,pelanggan, dan tiket untuk kd_Pesawat ='M-3' urutkan berdasarkan kd_pesawat

76 76 select rute.kd_rute, rute, pesawat.kd_pesawat, sum(harga) as TotalBiaya from rute, pesawat, pelanggan, tiket where pelanggan.kd_plg = tiket.kd_plg and rute.kd_rute=tiket.kd_rute and pesawat.kd_rute=rute.kd_rute group by rute.kd_rute, rute, pesawat.kd_pesawat 3. Tampilkan kd_rute, rute, kd_pesawat, sum(harga) dari tabel rute, pesawat, pelanggan, dan tiket urutkan berdasarkan kd_pesawat

77 77

78 78 select kabupaten.kd_Kab, Nm_Kab, pangan.Kd_Pangan, Nm_Pangan, satuan, klmpk_pangan, stock, bulan, produksi, jumlah_sedia, kebutuhan, jumlah_minta, (stock+produksi)- (kebutuhan+jumlah_minta) as Sisa from pangan, kabupaten, ketersediaan where pangan.kd_pangan=ketersediaan.kd_pangan and kabupaten.kd_kab=ketersediaan.kd_kab and kabupaten.kd_Kab in ('K001','K004','K002') order by kabupaten.kd_Kab 1. Tampilkan kd_Kab, Nm_Kab,Kd_Pangan, Nm_Pangan, satuan, klmpk_pangan, stock, bulan, produksi, jumlah_sedia, kebutuhan, jumlah_minta, dan sisa (stock+produksi)-(kebutuhan+jumlah_minta) dari tabel pangan, kabupaten, dan ketersediaan untuk kd_Kab 'K001','K004', dan 'K002‘ urutkan berdasarkan kd_Kab

79 79 select kabupaten.kd_Kab, Nm_Kab, pangan.Kd_Pangan, Nm_Pangan, satuan, klmpk_pangan, stock, bulan, produksi, jumlah_sedia, kebutuhan, jumlah_minta, (stock+produksi)-(kebutuhan+jumlah_minta) as Sisa from pangan, kabupaten, ketersediaan where pangan.kd_pangan=ketersediaan.kd_pangan and kabupaten.kd_kab=ketersediaan.kd_kab and bulan between '01-feb-09' and '01- aug-09' order by kabupaten.kd_Kab 2. Tampilkan kd_Kab, Nm_Kab,Kd_Pangan, Nm_Pangan, satuan, klmpk_pangan, stock, bulan, produksi, jumlah_sedia, kebutuhan, jumlah_minta, dan sisa (stock+produksi)-(kebutuhan+jumlah_minta) dari tabel pangan, kabupaten, dan ketersediaan untuk bulan Februari s/d agustus 2009

80 80 select kabupaten.kd_Kab, Nm_Kab, sum(stock), sum(produksi), sum(jumlah_sedia), sum(kebutuhan), sum(jumlah_minta), sum((stock+produksi)- (kebutuhan+jumlah_minta)) as Sisa from pangan, kabupaten, ketersediaan where pangan.kd_pangan=ketersediaan.kd_pangan and kabupaten.kd_kab = ketersediaan.kd_kab group by kabupaten.kd_Kab, Nm_Kab order by kabupaten.kd_Kab 3. Tampilkan kabupaten.kd_Kab, Nm_Kab, sum(stock), sum(produksi), sum(jumlah_sedia), sum(kebutuhan), sum(jumlah_minta), sum((stock+produksi)-(kebutuhan+jumlah_minta)) dari tabel pangan, kabupaten, dan ketersediaan urutkan berdasarkan kd_kab

81 81

82 82 select tamu.No_Id, Nama, Alamat, kamar.No_Kamar, type, jenis, tarif, No_Faktur, Tgl_Masuk as cekin, Tgl_Keluar as cekout from tamu, kamar, transaksi1 where tamu.No_Id=transaksi1.No_Id and kamar.No_Kamar=transaksi1.No_Kamar 1. Tampilkan No_Id, Nama, Alamat, No_Kamar, type, jenis, tarif, No_Faktur, Tgl_Masuk, Tgl_Keluar, lama=(Tgl_Keluar-Tgl_Masuk), Biaya_Adm, TotalBiaya=((Tgl_Keluar-Tgl_Masuk))*tarif)+Biaya_Adm dari tabel tamu, kamar, transaksi1 urut berdasarkan NO_Id

83 83 select tamu.No_Id, Nama, Alamat, kamar.No_Kamar, type, jenis, tarif, No_Faktur, Tgl_Masuk as cekin, Tgl_Keluar as cekout, (Tgl_Keluar-Tgl_Masuk) as Lama, Biaya_Adm as Adm, (to_Number((Tgl_Keluar-Tgl_Masuk))*tarif)+Biaya_Adm as TotBiaya from tamu, kamar, transaksi1 where tamu.No_Id=transaksi1.No_Id and kamar.No_Kamar=transaksi1.No_Kamar and alamat in ('Aceh','Padang','Palembang','Medan') 2. Tampilkan No_Id, Nama, Alamat, No_Kamar, type, jenis, tarif, No_Faktur, Tgl_Masuk, Tgl_Keluar, lama=(Tgl_Keluar-Tgl_Masuk), Biaya_Adm, TotalBiaya=((Tgl_Keluar-Tgl_Masuk))*tarif)+Biaya_Adm dari tabel tamu, kamar, transaksi1 urut berdasarkan NO_Id untuk wilayah pulau sumatera

84 84 select tamu.No_Id, Nama, Alamat, kamar.No_Kamar, type, jenis, tarif, No_Faktur, Tgl_Masuk as cekin, Tgl_Keluar as cekout, (Tgl_Keluar-Tgl_Masuk) as Lama, Biaya_Adm as Adm, (to_Number((Tgl_Keluar-Tgl_Masuk))*tarif)+Biaya_Adm as TotBiaya from tamu, kamar, transaksi1 where tamu.No_Id=transaksi1.No_Id and kamar.No_Kamar=transaksi1.No_Kamar and tgl_keluar between '12-may-09' and '18-may-09'; 3. Tampilkan No_Id, Nama, Alamat, No_Kamar, type, jenis, tarif, No_Faktur, Tgl_Masuk, Tgl_Keluar, lama=(Tgl_Keluar- Tgl_Masuk), Biaya_Adm, TotalBiaya=((Tgl_Keluar-Tgl_Masuk))*tarif)+Biaya_Adm dari tabel tamu, kamar, transaksi1 urut berdasarkan NO_Id yang telah check-in pada tanggal '12-may-09' sampai dengan '18-may-09';


Download ppt "1 H. SUMIJAN, Ir, M.Sc, MCP, OCP STAF PENGAJAR Universitas Putra Indonesia “YPTK”"

Presentasi serupa


Iklan oleh Google