Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 2008
»
SQL Server Newbies
»
Need help with Select statement!!
13 posts, Page 1 of 2
1
2
»»
Need help with Select statement!!
Rate Topic
Display Mode
Topic Options
Author
Message
yasser.akhan
yasser.akhan
Posted Friday, March 22, 2013 2:22 PM
Forum Newbie
Group: General Forum Members
Last Login: Friday, March 22, 2013 5:45 PM
Points: 3,
Visits: 4
final project is due tonight at midnight and i cant finish up these select statements
a. Find all those customers who have not purchased anything from Niles Video Inc.
b. Get the total number of DVDs and video tapes sold per genre.
c. Get the average number of DVDs per purchase.
heres the er model
followed by the relational
please let me know if my er model or relational model is wrong
Post #1434511
Sean Lange
Sean Lange
Posted Friday, March 22, 2013 2:43 PM
SSCrazy Eights
Group: General Forum Members
Last Login: Today @ 9:04 AM
Points: 8,596,
Visits: 8,236
Select statements usually come from tables. The pictures don't do much.
_______________________________________________________________
Need help? Help us help you.
Read the article at
http://www.sqlservercentral.com/articles/Best+Practices/61537/
for best practices on asking questions.
Need to split a string? Try Jeff Moden's
splitter
.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Post #1434515
opc.three
opc.three
Posted Friday, March 22, 2013 2:53 PM
SSCertifiable
Group: General Forum Members
Last Login: Today @ 9:12 AM
Points: 6,712,
Visits: 11,745
Please provide:
1. DDL in the form of CREATE TABLE statements to create your sample tables
2. DML in the form of INSERT INTO statements to populate the sample tables
3. The expected results of your SELECT statements based on that sample data
4. Most importantly: what you have tried so far.
__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community.
--Plato
Believe you can and you're halfway there.
--Theodore Roosevelt
Everything Should Be Made as Simple as Possible, But Not Simpler
--Albert Einstein
The significant problems we face cannot be solved at the same level of thinking we were at when we created them.
--Albert Einstein
1 apple is not exactly 1/8 of 8 apples. Because there are no absolutely identical apples.
--Giordy
Post #1434518
Lynn Pettis
Lynn Pettis
Posted Friday, March 22, 2013 3:42 PM
SSC-Insane
Group: General Forum Members
Last Login: Today @ 8:07 AM
Points: 21,604,
Visits: 27,434
Maybe I will look at this tomorrow.
Lynn Pettis
For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here
or
when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here
and
here
Managing Transaction Logs
SQL Musings from the Desert
Fountain Valley SQL
(My Mirror Blog)
Post #1434537
yasser.akhan
yasser.akhan
Posted Friday, March 22, 2013 3:42 PM
Forum Newbie
Group: General Forum Members
Last Login: Friday, March 22, 2013 5:45 PM
Points: 3,
Visits: 4
Oh srry about that, its a rather long project so i tried to spare some goring detail but here.
CREATE DATABASE Webstore
CREATE TABLE Customers
(
Customer_ID number(5) not null primary key,
Name varchar2(32) not null,
Shipping_Address varchar2(32) not null,
Email varchar2(32) not null,
Credit_Card# integer(16) not null,
);
CREATE TABLE Movies
(
Barcode number(3) not null ,
Title Varchar2(32),
Genre Varchar2(32) not null,
Year Number(4)
Media_Type Char(1) not null,
Cost money not null,
CONSTRAINT Medt primary key (barcode)
);
CREATE TABLE DVD
(
Format char(10) not null,
Cost money not null,
Quantity number(2) not null,
CONSTRAINT Medt
Foreign Key(barcode) references Movies(barcode),
);
CREATE TABLE Videos
(
Format char(10) not null,
Cost money not null,
Quantity number(2) not null,
CONSTRAINT Medt
Foreign Key(barcode) references Movies(barcode),
);
Insert Statement
INSERT INTO CustomerVALUES (11111, ‘Mike Smith’, ‘111 Ship Lane, IL 67892’, ‘mikesmith@gmail.com’, 1234 5678 9101 1121);
INSERT INTO CustomerVALUES (22222, ‘John Doe’, ‘222 Miss Lane, IL 64592’, ‘jdoe@gmail.com’, 9876 5678 9101 3456);
INSERT INTO CustomerVALUES (33333, ‘Rick Slick’, ‘333 tree Lane, IL 61253’, ‘slickrick@gmail.com’, 4589 5980 1256 1631)
INSERT INTO CustomerVALUES (44444, ‘Cheap Guy’, ‘444 cheap Lane, IL 60007’, ‘nothing@gmail.com’, 1276 5980 9876 1631)
INSERT INTO MoviesVALUES (223, ‘Dark Knight’, ‘Action’, 2013, ‘D’, $20.00);
INSERT INTO MoviesVALUES (132, ‘Titanic’, ‘Romance’, 1998, ‘V’, $8.00);
INSERT INTO MoviesVALUES (213, ‘Avengers’, ‘Action’, 2013, ‘D’, $20.00);
INSERT INTO MoviesVALUES (145, ‘Lion King’, ‘Children’, 1996, ‘V’, $6.00);
INSERT INTO SalesVALUES (10, $28.00, 11/3/2013, 157, 11111);
INSERT INTO SalesVALUES (11, $40.00, 10/28/2013, 289, 22222);
INSERT INTO SalesVALUES (12, $6.00, 11/10/2013, 865, 33333);
INSERT INTO SalesVALUES (13, $20.00, 11/11/2013, 865, 33333);
INSERT INTO DVDVALUES (‘DVDd’, $100.00, 5, 223);
INSERT INTO VideoVALUES (‘SVHS’, $32.00, 4, 132 );
INSERT INTO MoviesVALUES (‘DVDplus’, $100.00, 5, 213);
INSERT INTO VideoVALUES (‘VHS’, $60.00, 10, 145);
i was told to forget about the shopping cart.
Post #1434538
opc.three
opc.three
Posted Friday, March 22, 2013 4:28 PM
SSCertifiable
Group: General Forum Members
Last Login: Today @ 9:12 AM
Points: 6,712,
Visits: 11,745
That looks like Oracle code
__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community.
--Plato
Believe you can and you're halfway there.
--Theodore Roosevelt
Everything Should Be Made as Simple as Possible, But Not Simpler
--Albert Einstein
The significant problems we face cannot be solved at the same level of thinking we were at when we created them.
--Albert Einstein
1 apple is not exactly 1/8 of 8 apples. Because there are no absolutely identical apples.
--Giordy
Post #1434543
opc.three
opc.three
Posted Friday, March 22, 2013 4:34 PM
SSCertifiable
Group: General Forum Members
Last Login: Today @ 9:12 AM
Points: 6,712,
Visits: 11,745
You;re really making us work over here...
I tried polishing up the SQL you provided so it would run on SQL Server but it's not even close. Syntax errors everywhere, mis-aligned columns on the insert, constraints reffing non-existent columns.
Try again?
Oracle code is fine, we can easily switch it to run on SQL Server and we can write ANSI-standard SELECT statements that will run on both.
PS ...oh yeah, and this time, expected results would be nice, and
show us what you have tried
__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community.
--Plato
Believe you can and you're halfway there.
--Theodore Roosevelt
Everything Should Be Made as Simple as Possible, But Not Simpler
--Albert Einstein
The significant problems we face cannot be solved at the same level of thinking we were at when we created them.
--Albert Einstein
1 apple is not exactly 1/8 of 8 apples. Because there are no absolutely identical apples.
--Giordy
Post #1434546
yasser.akhan
yasser.akhan
Posted Friday, March 22, 2013 5:47 PM
Forum Newbie
Group: General Forum Members
Last Login: Friday, March 22, 2013 5:45 PM
Points: 3,
Visits: 4
meh dont worry about it, it was sort of a last ditch effort. thanks for looking at it though
Post #1434553
kevaburg
kevaburg
Posted Monday, March 25, 2013 7:58 AM
SSC-Enthusiastic
Group: General Forum Members
Last Login: Today @ 8:00 AM
Points: 159,
Visits: 190
Sorry for saying this but whether it is PL-SQL or T-SQL is somewhat irrelevant......the results you expected are somewhat basic and not particularly taxing. Are you sure this person had the right to expect you to perform a task like this....?
Post #1434930
Lynn Pettis
Lynn Pettis
Posted Monday, March 25, 2013 8:39 AM
SSC-Insane
Group: General Forum Members
Last Login: Today @ 8:07 AM
Points: 21,604,
Visits: 27,434
kevaburg (3/25/2013)
Sorry for saying this but whether it is PL-SQL or T-SQL is somewhat irrelevant......the results you expected are somewhat basic and not particularly taxing. Are you sure this person had the right to expect you to perform a task like this....?
Curious, to whom was this comment addressed?
Lynn Pettis
For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here
or
when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here
and
here
Managing Transaction Logs
SQL Musings from the Desert
Fountain Valley SQL
(My Mirror Blog)
Post #1434946
« Prev Topic
|
Next Topic »
13 posts, Page 1 of 2
1
2
»»
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.