Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

Using Case?

$
0
0
Hi all
I'm trying to create a view that calculates the business days for a certain processes.
P1 to p48 are the processes names.
Exp p48 =duedate-1 day, p47= 7 days from p48
I have created a function name Pdates that calculates the business days and it is working.
This is what I have .

Code:

CREATE
    ALGORITHM = UNDEFINED
    DEFINER = `root`@`localhost`
    SQL SECURITY DEFINER
VIEW `test2` AS
    select
        `project`.`prjAddress` AS `Projet`,
        `project`.`prjDueDate` AS `Datte`,
                `processes`.`proPName` AS `Name`,
                process.propDate AS FrmProcess,
        `processes`.`proPValue` AS `Value`,
                `colors`.`colCategory` as Color,
      Case Process.proPDate
                When 'p47' then production.PDates(Test2.`Date`,test2.Value)
else
 if((`processes`.`proPValue` = 0),
            `project`.`prjDueDate`,
            `production`. `PDates` (`project`.`prjDueDate`,
                    `processes`.`proPValue`)) AS `NewDates`,
 End
Where test2.prjid= project.prjid AND test2.Name='p47'
        `processes`.`Rule` AS `rule`
    from
        processes
                join project
                Left join colors ON colors.colID=specs.colID
                test2
    order by Projet,processes.ProID desc

I Get syntax error," unexpected AS Expecting END"
on the first AS newdate.

Thanks in advance

Viewing all articles
Browse latest Browse all 13329

Trending Articles