Table ordering help

Antuan Johnson amjohnson09 at gmail.com
Sat Feb 7 11:14:53 CST 2009


I have to update the column(Chart_Position) based on the order of
column(sales) each week. So I guess dream code

would look like Update T1 Set Chart_Position = Temprecid ORDER BY Sales DESC

I had an alternative way before Valentina but it doesn't seem possible now
because ORDER BY is not allowed to be used in INSERT statements, and I'm
not knowledgeable of cursors or procedures so any help is appreciated. Heres
the code I developed before.

BEGIN TRANSACTION;
CREATE TEMPORARY TABLE chart_backup(Act String,Sales
Long,Chart_Position BYTE);
INSERT INTO chart_backup SELECT Discs.Act, Discs.Sales,
Discs.Chart_Position FROM Discs ORDER BY Sales Desc;
CREATE TABLE newchart(Act String,Sales Long,Chart_Position BYTE;
INSERT INTO newchart(Act,Sales,chart_backup) SELECT
Act,Sales,Chart_Position FROM chart_backup
COMMIT;
update Discs Set P=(Select recid from  chart_backup WHERE
chart_backup.Sales=Discs.Sales)

-- 
Wolverine Studios,
Lead Developer of MWR
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macserve.net/pipermail/valentina/attachments/20090207/6d5b2c50/attachment.html 


More information about the Valentina mailing list