Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
SQL Confused
Starting Member
2 Posts |
Posted - 2013-10-18 : 18:22:42
|
Hey all,I'm taking a class on SQL databases, and I'm struggling cause it's online so examples are lacking, and the ability to ask questions are limited.I have this assignment:The Oracle Server may be used to test and compile the SQL Queries developed for this assignment. Your instructor will provide you with login credentials to a University maintained Oracle server.Imagine that you have been hired as a consultant to assist in streamlining the data processing of an international based organization that sells high-end electronics. The organization has various departments such as payroll, human resources, finance, marketing, sales, and operations. The sales department is the only department where employees are paid a commission in addition to their yearly salary and benefits. All other departments compensate their employees with a yearly salary and benefits only. Commission is paid by multiplying the employee’s commission rate by the total amount of product units sold. You have access to the following data sets:Employee (EmpNumber, EmpFirstName, EmpLastName, CommissionRate, YrlySalary, DepartmentID, JobID)Invoice (InvNumber, InvDate, EmpNumber, InvAmount)InvoiceLine (InvLineNumber, InvNumber, ProductNumber, Quantity)Product (ProductNumber, ProductDescription, ProductCost)Department (DepartmentID, DepartmentDescription)Job (JobID, JobDescription)Design a query that will allow the finance department to determine the commissions paid to specific employees of the sales department for the month of December. Note: You will need to generate the tables described above (Employee, Invoice, InvoiceLine, Product, Department, and Job) in order to compare and validate your code. Validated query code must be part of your paper.I know this is incredibly basic, but how do I generate the query code?As an example, I've tried:create table employee (column 1 empnumbercolumn 2 emplastnamecolumn 3 empfirstname );just to try to generate a table so I know I have the syntax right.But despite my variations, I keep getting errors thrown at me. I know this is pretty basic, but can anyone give me an example of a working query? |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2013-10-18 : 18:28:37
|
You'll want to post your question on a site that's for Oracle. SQLTeam.com is for Microsoft SQL Server and sometimes Microsoft Access.Tara KizerSQL Server MVP since 2007http://weblogs.sqlteam.com/tarad/ |
 |
|
SQL Confused
Starting Member
2 Posts |
Posted - 2013-10-18 : 18:40:00
|
And good times.Thanks for the response. |
 |
|
bitsmed
Aged Yak Warrior
545 Posts |
Posted - 2013-10-19 : 06:46:43
|
Maybe this (You have to fill in some data to test on yourself)create table department ( departmentid number ,departmentdescription varchar2(255) ,constraint pk_department primary key(departmentid));create table product ( productnumber number ,productdescription varchar2(255) ,productcost number(13,2) ,constraint pk_product primary key(productnumber));create table job ( jobid number ,jobdescription varchar2(255) ,constraint pk_job primary key(jobid));create table employee ( empnumber number ,empfirstname varchar2(255) ,emplastname varchar2(255) ,commissionrate number(13,2) ,yrlysalary number(13,2) ,departmentid number ,jobid number ,constraint pk_employee primary key(empnumber) ,constraint fk_employee_department foreign key (departmentid) references department(departmentid) ,constraint fk_employee_job foreign key (jobid) references job(jobid));create table invoice ( invnumber number ,invdate date ,empnumber number ,invamount number(13,2) ,constraint pk_invoide primary key(invnumber) ,constraint fk_invoice_employee foreign key (empnumber) references employee(empnumber));create table invoiceline ( invlinenumber number ,invnumber number ,productnumber number ,quantity number ,constraint pk_invoiceline primary key(invnumber,invlinenumber) ,constraint fk_invoiceline_invoice foreign key (invnumber) references invoice(invnumber) ,constraint fk_invoiceline_product foreign key (productnumber) references product(productnumber));select * from employee as a inner join department as b on b.departmentid=a.departmentid inner join invoice as c on c.empnumber=a.empnumber where b.departmentdescription='Sales' and c.invdate between to_date('20121201','YYYYMMDD') and to_date('20121231','YYYYMMDD') |
 |
|
|
|
|
|
|