Results 1 to 4 of 4

Thread: Using Case?

  1. #1
    Join Date
    Mar 2010
    Posts
    26

    Unanswered: Using Case?

    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
    VIPER

  2. #2
    Join Date
    Sep 2009
    Location
    San Sebastian, Spain
    Posts
    880
    You where clause is in the wrong place.
    Ronan Cashell
    Certified Oracle DBA/Certified MySQL Expert (DBA & Cluster DBA)
    http://www.it-iss.com
    Follow me on Twitter

  3. #3
    Join Date
    Mar 2010
    Posts
    26
    Thanks for your reply
    Can you please help me by directing me to some documention that would help me on where to place the WHERE clause or show me.
    VIPER

  4. #4
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    If you haven't used them before, you really ought to find the MySQL manual web pages. They are quite helpful!

    The MySQL :: MySQL 5.0 Reference Manual :: 13.2.8 SELECT Syntax has the information that you requested.

    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •