Not Boring Movies

Write an SQL query to report the movies with an odd-numbered ID and a description that is not "boring". Return the result table ordered by rating in descending order.

table name: Cinema


Solution:

select * from Cinema where id%2 >0 and description not like '%boring%' order by rating desc

Output:

SQL Script:

CREATE TABLE [dbo].[Cinema](
       [id][int] NOT NULL,
       [movie][varchar](50) NULL,
       [description][varchar](50) NULL,
       [rating][float] NULL,
 CONSTRAINT [PK_Cinema] PRIMARY KEY CLUSTERED
(
       [id]
ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO
INSERT [dbo].[Cinema] ([id], [movie], [description], [rating]) VALUES (1, N'War', N'great 3D', 8.9)
GO
INSERT [dbo].[Cinema] ([id], [movie], [description], [rating]) VALUES (2, N'Science', N'fiction', 8.5)
GO
INSERT [dbo].[Cinema] ([id], [movie], [description], [rating]) VALUES (3, N'irish', N'boring', 6.2)
GO
INSERT [dbo].[Cinema] ([id], [movie], [description], [rating]) VALUES (4, N'Ice song', N'Fantacy', 8.6)
GO
INSERT [dbo].[Cinema] ([id], [movie], [description], [rating]) VALUES (5, N'House card', N'Interesting ', 9.1)
GO


Comments (0)