Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 12»»

Need help with Select statement!! Expand / Collapse
Author
Message
Posted Friday, March 22, 2013 2:22 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum 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
Posted Friday, March 22, 2013 2:43 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: 2 days ago @ 2:24 PM
Points: 11,990, Visits: 11,007
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
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1434515
Posted Friday, March 22, 2013 2:53 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Wednesday, April 16, 2014 9:25 AM
Points: 7,070, Visits: 12,523
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
Posted Friday, March 22, 2013 3:42 PM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Today @ 3:22 PM
Points: 22,510, Visits: 30,232
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
Posted Friday, March 22, 2013 3:42 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum 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 Customer VALUES (11111, ‘Mike Smith’, ‘111 Ship Lane, IL 67892’, ‘mikesmith@gmail.com’, 1234 5678 9101 1121);
INSERT INTO Customer VALUES (22222, ‘John Doe’, ‘222 Miss Lane, IL 64592’, ‘jdoe@gmail.com’, 9876 5678 9101 3456);
INSERT INTO Customer VALUES (33333, ‘Rick Slick’, ‘333 tree Lane, IL 61253’, ‘slickrick@gmail.com’, 4589 5980 1256 1631)
INSERT INTO Customer VALUES (44444, ‘Cheap Guy’, ‘444 cheap Lane, IL 60007’, ‘nothing@gmail.com’, 1276 5980 9876 1631)



INSERT INTO Movies VALUES (223, ‘Dark Knight’, ‘Action’, 2013, ‘D’, $20.00);
INSERT INTO Movies VALUES (132, ‘Titanic’, ‘Romance’, 1998, ‘V’, $8.00);
INSERT INTO Movies VALUES (213, ‘Avengers’, ‘Action’, 2013, ‘D’, $20.00);
INSERT INTO Movies VALUES (145, ‘Lion King’, ‘Children’, 1996, ‘V’, $6.00);


INSERT INTO Sales VALUES (10, $28.00, 11/3/2013, 157, 11111);
INSERT INTO Sales VALUES (11, $40.00, 10/28/2013, 289, 22222);
INSERT INTO Sales VALUES (12, $6.00, 11/10/2013, 865, 33333);
INSERT INTO Sales VALUES (13, $20.00, 11/11/2013, 865, 33333);


INSERT INTO DVD VALUES (‘DVDd’, $100.00, 5, 223);
INSERT INTO Video VALUES (‘SVHS’, $32.00, 4, 132 );
INSERT INTO Movies VALUES (‘DVDplus’, $100.00, 5, 213);
INSERT INTO Video VALUES (‘VHS’, $60.00, 10, 145);



i was told to forget about the shopping cart.
Post #1434538
Posted Friday, March 22, 2013 4:28 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Wednesday, April 16, 2014 9:25 AM
Points: 7,070, Visits: 12,523
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
Posted Friday, March 22, 2013 4:34 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Wednesday, April 16, 2014 9:25 AM
Points: 7,070, Visits: 12,523
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
Posted Friday, March 22, 2013 5:47 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum 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
Posted Monday, March 25, 2013 7:58 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Monday, April 14, 2014 8:19 AM
Points: 306, Visits: 461
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
Posted Monday, March 25, 2013 8:39 AM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Today @ 3:22 PM
Points: 22,510, Visits: 30,232
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 »

Add to briefcase 12»»

Permissions Expand / Collapse