create a temporary table

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • parallax
    New Member
    • Apr 2007
    • 10

    create a temporary table

    hi guys,

    how could i create and send this
    [HTML]SELECT d.name, d.missing, f.salario, (SELECT SUM(advanced) FROM data d2 WHERE d.name=d2.name) AS AdvanceSum from data d JOIN empregados f ON f.name = d.name where MONTH(d.date) = 4 group by name;[/HTML]
    to a temporary table??
    i have to add this select in a temporary table and make a calculation between the sum(advanced) and the f.salario but i have no idea of how to write the code...

    thanks
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    Originally posted by parallax
    hi guys,

    how could i create and send this
    [HTML]SELECT d.name, d.missing, f.salario, (SELECT SUM(advanced) FROM data d2 WHERE d.name=d2.name) AS AdvanceSum from data d JOIN empregados f ON f.name = d.name where MONTH(d.date) = 4 group by name;[/HTML]
    to a temporary table??
    i have to add this select in a temporary table and make a calculation between the sum(advanced) and the f.salario but i have no idea of how to write the code...

    thanks
    Code:
    CREATE VIEW `View_PayrollOrWhatever` AS SELECT d.name, d.missing, f.salario, (SELECT SUM(advanced) FROM data d2 WHERE d.name=d2.name) AS AdvanceSum from data d JOIN empregados f ON f.name = d.name group by name;
    
    CREATE TEMPORARY TABLE `Temp_Data_PayrollOrWhatever` SELECT * FROM `View_PayrollOrWhatever` where MONTH(d.date) = 4;

    http://dev.mysql.com/doc/refman/5.0/...ate-table.html (look towards the bottom)
    Last edited by pbmods; May 5 '07, 07:30 PM. Reason: Added MySQL Documentation Links

    Comment

    Working...