Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

another syntax like this

compilemancompileman Posts: 2Member
create table sailors(
sid int not null,
sname char(20) not null,
rating int,
age decimal,
constraint pk_sailors primary key(sid)
)
create table boats(
bid int not null,
bname char(10) not null,
color char(10) not null,
constraint pk_boats primary key(bid)
)
create table reserves(
sid int not null,
bid int not null,
reserveDate datetime not null,
constraint fk_reservesSid foreign key(sid) references sailors(sid),
constraint fk_reservesBid foreign key(bid) references boats(bid),
)

insert into sailors(sid,sname,rating,age) values('22','Dustin','7','45.0')
insert into sailors(sid,sname,rating,age) values('29','Brutus','1','33.0')
insert into sailors(sid,sname,rating,age) values('31','Lubber','8','55.5')
insert into sailors(sid,sname,rating,age) values('32','Andy','8','25.5')
insert into sailors(sid,sname,rating,age) values('58','Rudy','10','35.0')
insert into sailors(sid,sname,rating,age) values('64','Horatio','7','35.0')
insert into sailors(sid,sname,rating,age) values('71','Zorba','10','16.0')
insert into sailors(sid,sname,rating,age) values('74','Horatio','9','25.5')
insert into sailors(sid,sname,rating,age) values('85','Art','3','63.5')
insert into sailors(sid,sname,rating,age) values('95','Bob','3','35.0')

insert into boats(bid,bname,color) values('101','Interlake','blue')
insert into boats(bid,bname,color) values('102','Interlake','red')
insert into boats(bid,bname,color) values('103','Clipper','green')
insert into boats(bid,bname,color) values('104','Marine','red')

insert into reserves(sid,bid,reserveDate) values('22','101','10/10/08')
insert into reserves(sid,bid,reserveDate) values('22','102','10/10/08')
insert into reserves(sid,bid,reserveDate) values('22','103','10/08/08')
insert into reserves(sid,bid,reserveDate) values('22','104','10/07/08')
insert into reserves(sid,bid,reserveDate) values('31','102','11/10/08')
insert into reserves(sid,bid,reserveDate) values('31','103','11/06/08')
insert into reserves(sid,bid,reserveDate) values('31','104','11/12/08')
insert into reserves(sid,bid,reserveDate) values('64','101','09/05/08')
insert into reserves(sid,bid,reserveDate) values('64','102','09/08/08')
insert into reserves(sid,bid,reserveDate) values('74','103','09/08/08')

select * from boats
select * from sailors
select * from reserves

[color=Blue]select dbo.sailors.sid, dbo.sailors.sname, count(dbo.reserves.bid) as banyak from dbo.boats inner join
dbo.reserves on dbo.boats.bid = dbo.reserves.bid inner join dbo.sailors on dbo.reserves.sid = dbo.sailors.sid
group by dbo.sailors.sid, dbo.sailors.sname
having (count(dbo.reserves.bid)>1)[/color]



drop table boats
drop table reserves
drop table sailors
------------------------------------------------

Can you help me to make another syntax from syntax that mark on blue color?
I think that syntax is so difficult.can you make another simple syntax plz.
thanks

Sign In or Register to comment.