TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
shamsundar bobade
NA
24
10.5k
Query
Feb 19 2014 6:31 AM
DECLARE
@SongYear varchar(50),
@YearBack varchar(50),
@YearPost varchar(50),
@Singer varchar(50),
@Composer varchar(50)
--Song Option First By Year +/- 3
set @SongYear=(select [year] from tbl_SongMaster where song_id=@songid)
set @YearBack=@SongYear-3
set @YearPost=@SongYear+3
select top(1)song As FirstOption from tbl_SongMaster where year between @YearBack and @YearPost ORDER BY NEWID()
--Song Option Second By Same Singer
set @Singer=(select singer1 from tbl_SongMaster where song_id=@songid)
select Top(1) song as SecondOption from tbl_SongMaster where singer1=@Singer order by NEWID()
--Song Option Third And Fourth By Composer
set @Composer=(select composer1 from tbl_SongMaster where song_id=@songid)
select top(2) song from tbl_SongMaster where composer1=@Composer order by NEWID()
i get three result can i combine it in one result plz answer fast
Reply
Answers (
3
)
how to more than 2 nasted quries
how to change the default date in sql server