06.28.06
Posted in Microsoft at 8:51 pm by gloomy
Well, Microsoft has stepped even further into open source. Some time ago they have opened an open source community portal - codeplex.com - a nice place for those who are developing open source projects based on microsoft technology and for those who have interest in such projects. So grab a free copy of Visual studio Express 2005 and go coding. I have been using Visual Studio Express 2005 for a while and find codeplex combined with msdn quite useful.
Permalink
06.14.06
Posted in MySQL at 10:41 pm by gloomy
How to make MySQL return a desired percentage of rows?
Some people time after time ask this question. Most of
them are migrating from MsSQL (Microsoft SQL Server 2xxx) that
has the ability to retrieve a desired percentage of rows. For example:
SELECT TOP 50 PERCENT * FROM table
This query will return 50% of rows. Nice. What do you do
in MySQL if you get a task “to return half of the records from a table”?
So far i found just one easy solution for MySQL 5.0.7+ version:
SELECT @percentage := ROUND(COUNT(*) * 50/100) FROM table;
PREPARE STMT FROM 'SELECT * FROM table LIMIT ?';
EXECUTE STMT USING @percentage;
Any thoughts?
Permalink