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.

 All Forums
 General SQL Server Forums
 Database Design and Application Architecture
 sql query: producing report

Author  Topic 

vik
Starting Member

8 Posts

Posted - 2010-03-14 : 09:44:54
i need to answer an sql query as i am having difficulty on it. the query is:

Produce a report that shows for each event with a start_date of April 1st 2010 or later: the event description, each performance date, and the number of seats sold for that performance.

here is my sql script:

CREATE TABLE EVENT (
EVENT_NO CHAR(5) NOT NULL,
EVENT_DESCRIPTION CHAR(35) NOT NULL,
START_DATE DATE,
END_DATE DATE,
AVERAGE_LENGTH NUMBER(2),
CONSTRAINT EVENT_PRIMARY_KEY PRIMARY KEY (EVENT_NO));

INSERT INTO EVENT VALUES ('E0001', 'PETER PAN', '19-APR-10', '29-APR-10', 90);
INSERT INTO EVENT VALUES ('E0003', 'CHRIS ROCK', '25-OCT-10', '25-NOV-10', 60);
INSERT INTO EVENT VALUES ('E0005', 'LION KING', '14-JAN-10', '30-MAR-10', 90);
INSERT INTO EVENT VALUES ('E0007', 'DRACULA', '10-APR-10', '30-APR-10', 70);
INSERT INTO EVENT VALUES ('E0009', 'SNOW WHITE', '01-DEC-10', '30-DEC-10', 90);
INSERT INTO EVENT VALUES ('E0013', 'SLEEPING BEAUTY', '12-MAY-10', '12-AUG-10', 90);
INSERT INTO EVENT VALUES ('E0020', 'STOMP', '16-APR-10', '18-APR-10', 70);
INSERT INTO EVENT VALUES ('E0025', 'PINOCCHIO', '26-SEP-10', '26-OCT-10', 90);
INSERT INTO EVENT VALUES ('E0029', 'PIRATES', '03-JAN-10', '03-MAY-10', 50);
INSERT INTO EVENT VALUES ('E0030', 'BAMBY', '15-DEC-10', '30-DEC-10', 90);



CREATE TABLE PERFORMANCE (
PERFORMANCE_NO CHAR(5) NOT NULL,
EVENT_NO CHAR(5),
PERF_DATE DATE,
START_TIME CHAR(5),
ACTUAL_END_TIME CHAR(5),
SOLD_SEATS NUMBER(3) NOT NULL,
CONSTRAINT PERFORMANCE_FOREIGN_KEY FOREIGN KEY (EVENT_NO) REFERENCES EVENT(EVENT_NO),

CONSTRAINT PERFORMANCE_PRIMARY_KEY PRIMARY KEY (PERFORMANCE_NO));

INSERT INTO PERFORMANCE VALUES ('PE003', 'E0001', '19-APR-10', '14.00', '15.30', 210);
INSERT INTO PERFORMANCE VALUES ('PE004', 'E0001', '29-APR-10', '14.00', '15.30', 140);
INSERT INTO PERFORMANCE VALUES ('PE005', 'E0003', '25-OCT-10', '21.00', '22.00', 202);
INSERT INTO PERFORMANCE VALUES ('PE006', 'E0003', '25-NOV-10', '21.00', '22.00', 103);
INSERT INTO PERFORMANCE VALUES ('PE007', 'E0005', '14-JAN-10', '13.30', '15.00', 100);
INSERT INTO PERFORMANCE VALUES ('PE008', 'E0005', '14-FEB-10', '13.30', '15.00', 202);
INSERT INTO PERFORMANCE VALUES ('PE009', 'E0005', '30-MAR-10', '13.30', '15.00', 100);
INSERT INTO PERFORMANCE VALUES ('PE010', 'E0007', '10-APR-10', '19.30', '20.40', 104);
INSERT INTO PERFORMANCE VALUES ('PE011', 'E0007', '30-APR-10', '19.30', '20.40', 106);
INSERT INTO PERFORMANCE VALUES ('PE012', 'E0009', '01-DEC-10', '19.30', '21.00', 110);
INSERT INTO PERFORMANCE VALUES ('PE013', 'E0009', '10-DEC-10', '19.30', '21.00', 114);
INSERT INTO PERFORMANCE VALUES ('PE014', 'E0009', '15-DEC-10', '19.30', '21.00', 110);
INSERT INTO PERFORMANCE VALUES ('PE015', 'E0009', '30-DEC-10', '19.30', '21.00', 110);
INSERT INTO PERFORMANCE VALUES ('PE016', 'E0013', '12-MAY-10', '12.00', '13.30', 180);
INSERT INTO PERFORMANCE VALUES ('PE017', 'E0013', '12-AUG-10', '12.00', '13.30', 130);
INSERT INTO PERFORMANCE VALUES ('PE018', 'E0020', '16-APR-10', '13.00', '14.10', 109);
INSERT INTO PERFORMANCE VALUES ('PE020', 'E0020', '17-APR-10', '14.30', '15.40', 108);
INSERT INTO PERFORMANCE VALUES ('PE021', 'E0029', '03-JAN-10', '21.00', '21.50', 101);
INSERT INTO PERFORMANCE VALUES ('PE022', 'E0029', '03-FEB-10', '21.00', '21.50', 111);
INSERT INTO PERFORMANCE VALUES ('PE023', 'E0029', '03-MAR-10', '21.00', '21.50', 204);
INSERT INTO PERFORMANCE VALUES ('PE024', 'E0029', '03-APR-10', '21.00', '21.50', 201);
INSERT INTO PERFORMANCE VALUES ('PE025', 'E0029', '03-MAY-10', '21.00', '21.50', 201);
INSERT INTO PERFORMANCE VALUES ('PE026', 'E0030', '15-DEC-10', '13.30', '15.00', 123);
INSERT INTO PERFORMANCE VALUES ('PE027', 'E0030', '30-DEC-10', '13.30', '15.00', 178);

it says to "create a report", does that mean i need to "create view"?

any help on this would be appreciated

dataguru1971
Master Smack Fu Yak Hacker

1464 Posts

Posted - 2010-03-14 : 10:56:39
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=141317

Same question isn't it?



Poor planning on your part does not constitute an emergency on my part.

Go to Top of Page
   

- Advertisement -