Re: Query needed for this sol.

2007-04-09 Thread Baron Schwartz
Hi Abhishek, In a table i have 100s of rows with six categories like A,B,C,D,E,F which is marked with a column like Table ID Category 1 A 2 A 3 B 4 B 5 B 6 C 7 C and so on 100 ids for each of six categories , i want to delete all but 10 ids of each category, i wanted to know how to d

Re: Query needed for this sol.

2007-04-09 Thread Brent Baisley
Not sure how to do it in a single query, but if you run this query repeatedly, eventually you'll have only 10 left of each category. DELETE tableName FROM tableName, (SELECT MAX(ID) deleteID,count(ID) categCount FROM tableName GROUP BY Category HAVING categCount>10) AS Smry WHERE tableName.ID=S

Re: Query needed to convert varchar to int ....sorry previous posting was incomplete

2006-08-20 Thread Chris
VenuGopal Papasani wrote: Dear all, I have a table with the following structure. ield Type CollationNullKey Default Extra Privileges Comment --- -- -- --- -

Re: query needed

2006-08-16 Thread Michael Stassen
VenuGopal Papasani wrote: > Once again i send the table data: > > Code Period Value > c12004 22 > c12005 10 > c22005 15 > c32005 20 > c42005 15 > c52005 5 > c62005 30 >

RE: query needed

2006-08-13 Thread Peter Lauri
Not until we know the logic behind the "code" and how the calculations should be done. -Original Message- From: VenuGopal Papasani [mailto:[EMAIL PROTECTED] Sent: Monday, August 14, 2006 1:03 PM To: Peter Lauri; mysql@lists.mysql.com Subject: Re: query needed if it is stat

Re: query needed

2006-08-13 Thread VenuGopal Papasani
if it is static then it works fine.but we have lots of codes in a table which should be done similar operation.instead varifying staticly with c1,c2 can we make dynamic. On 8/14/06, Peter Lauri <[EMAIL PROTECTED]> wrote: SELECT SUM(IF(code='c1', code, IF(code='c2', code, 0))) - SUM(IF(code='c4'

RE: query needed

2006-08-13 Thread Peter Lauri
SELECT SUM(IF(code='c1', code, IF(code='c2', code, 0))) - SUM(IF(code='c4', code, IF(code='c5', code, 0))) FROM datavalue; -Original Message- From: VenuGopal Papasani [mailto:[EMAIL PROTECTED] Sent: Monday, August 14, 2006 11:26 AM To: mysql@lists.mysql.com Subject: query needed Hi, i

Re: query needed

2006-08-13 Thread VenuGopal Papasani
Once again i send the table data: Code Period Value c1 2004 22 c1 2005 10 c2 2005 15 c3 2005 20 c4 2005 15 c5 2005 5 c6 2005 30 c7 2005

Re: query needed

2006-08-13 Thread Chris
VenuGopal Papasani wrote: Hi, i got a table datavalue as follows code period value c1 20051 c2 20052 c32006 3