Quantcast 2 câu hỏi phỏng vấn Sql mà mình đã từng gặp.

2 câu hỏi phỏng vấn Sql mà mình đã từng gặp.

by Neon Quach 25. July 2011 22:01

Hỏi: Đếm tổng số record trong bảng product (northwind)? Có bao nhiêu cách để thực hiện?

Trả lời: Có 2 cách để thực hiện

select COUNT(*) from Products
select
COUNT(p.ProductName) from Products p

Hỏi: Lấy danh sách product từ mẫu tin thứ 10 đến đến thứ 50?

Trả lời: Dùng ROW_NUMBER chi tiết có thể xem tại đây

with Myproduct as(
select
p.ProductName, p.UnitPrice, p.Discontinued,
ROW_NUMBER
() over(order by p.productname desc) as 'RNumber' from Products p
)

select
* from Myproduct
where
RNumber between 10 and 50

That’s all

 

Tags:


Categories: sql

blog comments powered by Disqus

About me

I'm  currently employed as Software developer at devinition.com and also a Microsoft Certified Technology Specialist (MCTS), Microsoft Certified Professional Developer (MCPD) in Net Framework 2.0 and 3.5: Web Applications and MCTS .NET Framework 3.5, ADO.NET Applications

Powered by BlogEngine.NET 2.5.0.5 - Eco Theme by n3o Web Designers