-2

I am getting error in the partition clause. Please help me. The error is

 Select Model_Name,  
   Case Model_Subtype   
        When 'Weight' then 'Static'  
        When 'Linked Account' then 'Dynamic'  
        When 'Flexible' then 'Dynamic'  
       Else 'Not Defined'  
  End as Model_Type, Security_Name, Market_Value,Weight,  
  Case When Weight = 0 And Market_Value= 0 Then 0  
     When Weight  = 0 Then Cast(Market_Value/ nullif(SUM(market_Value)   
           OVER (Partition by Model_Name),0) AS Decimal (10,4))  
      When Weight !=0 Then Weight/100   
    Else Weight End as Target_Weight,  
         vehicle.Vehicle_Name  
    from   
  OFF_PRODUCT_MODEL model    
 Join OFF_PRODUCT_MODEL_TARGET target on target.Model_Id = model.Model_Id  
  Join OFF_PRODUCT_SECURITIES Sec on sec.Security_Id = target.Security_Id   
  left outer Join Offer_Back_End.tblStrategies Strategy on    Strategy.Vestmark_Sleeve_Code = model.Model_Name   
   left outer join Offer_Back_End.tblVehicles vehicle On vehicle.Vehicle_Id = strategy.Vehicle_ID
 Where (Strategy.Active_Strategy is null or Strategy.Active_Strategy = 1)  

Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(Partition by Model_Name),0) AS Decimal (10,4)) When Weight !=0 Then Weight/' at line 11

gen_Eric
  • 214,658
  • 40
  • 293
  • 332
user60811
  • 1
  • 3

2 Answers2

3

Umm, OVER (Partition by Model_Name) is analytical function which MySQL unfortunately doesn't support and don't have them and so you are getting the said error.

Rahul
  • 73,987
  • 13
  • 62
  • 116
  • Hi Rahul, Thank you for your quick reply. Can you please tell me how do I convert Over(Partition by Model_Name ) clause in MySQL? I appreciate for your help. – user60811 Sep 04 '15 at 13:47
0

MySQL does not support OVER() clause. In general Window Functions are not part of MySQL.

You can however emulate it - please refer to the following answer:

Community
  • 1
  • 1
Michał Szkudlarek
  • 1,235
  • 1
  • 18
  • 33