Freek's Blog

SQL en .NET vraagstukken en oplossingen die ik zoal tegenkom
posts - 199, comments - 123, trackbacks - 2, articles - 7

My Links

News

Google analytics script: Locations of visitors to this page

Article Categories

Archives

Post Categories

Image Galleries

Algemene links

MSDN

vb links

SELECT TOP X COLUMNS FROM TABLE

X = variable


Assignment: show only 5 percent of a given range.....


Solution:

declare @cntRows int

set @cntRows  = (select count(*) from tablename where date = getdate()) --set total

set @cntRows = (@cntRows * 0.05) --set 5 percent

select top (@cntRows ) * from tablename where date = getdate() order by newid() --get 5 percent of random records!!!!!

 

 

 

 

 

 

 

 

 

Post Comment

Title  
Name  
Url
Comment   

ATTENTION: the code you need to copy is CaSe SeNsItIvE and is required to prevent spam.
Enter the code you see: