This is a forum where members new and old can come to ask questions and get info and opinions. It is not a place to advertise your business or have other forms of advertising, whether it be in your posts or signature.

All links in the forum will not be indexed by Search Engines and any unapproved forms of advertising or spam will be dealt with accordingly, deleted, and that member's account banned.

Forums

Overview » SQL and Databases » If statement to be moved to SQL
Reply

If statement to be moved to SQL

Rick Beach
Member



Since: 20 Aug 2010
Posts: 5
Posted 20 Aug 2010 19:02:43

Below is a statement that I use in Access for a query. I need to create a view in SQL that will accomplish the same. I hope there is some GURU available that can assist me with this:

Amps: IIf([M].[Phase A Actual Amps]>0 And [M].[Phase B Actual Amps]>0 And [M].[Phase C Actual Amps]>0,([Phase A Actual Amps]+[Phase B Actual Amps]+[Phase C Actual Amps])/3,IIf(([M].[Phase A Actual Amps]=0) And ([M].[Phase B Actual Amps]>0) And ([M].[Phase C Actual Amps]>0),([Phase B Actual Amps]+[Phase C Actual Amps])/2,IIf(([M].[Phase A Actual Amps]>0) And ([M].[Phase B Actual Amps]=0) And ([M].[Phase C Actual Amps]>0),([Phase A Actual Amps]+[Phase C Actual Amps])/2,IIf(([M].[Phase A Actual Amps]>0) And ([M].[Phase B Actual Amps]>0) And ([M].[Phase C Actual Amps]=0),([Phase A Actual Amps]+[Phase B Actual Amps])/2,IIf(([M].[Phase A Actual Amps]>0) And ([M].[Phase B Actual Amps]=0) And ([M].[Phase C Actual Amps]=0),([Phase A Actual Amps]),IIf(([M].[Phase A Actual Amps]=0) And ([M].[Phase B Actual Amps]>0) And ([M].[Phase C Actual Amps]=0),([Phase B Actual Amps]),IIf(([M].[Phase A Actual Amps]=0) And ([M].[Phase B Actual Amps]=0) And ([M].[Phase C Actual Amps]>0),([Phase C Actual Amps]),0)))))))

Thanks,

Rick

Below is a statement that I use in Access for a query. I need to create a view in SQL that will accomplish the same. I hope there is some GURU available that can assist me with this:

Amps: IIf([M].[Phase A Actual Amps]>0 And [M].[Phase B Actual Amps]>0 And [M].[Phase C Actual Amps]>0,([Phase A Actual Amps]+[Phase B Actual Amps]+[Phase C Actual Amps])/3,IIf(([M].[Phase A Actual Amps]=0) And ([M].[Phase B Actual Amps]>0) And ([M].[Phase C Actual Amps]>0),([Phase B Actual Amps]+[Phase C Actual Amps])/2,IIf(([M].[Phase A Actual Amps]>0) And ([M].[Phase B Actual Amps]=0) And ([M].[Phase C Actual Amps]>0),([Phase A Actual Amps]+[Phase C Actual Amps])/2,IIf(([M].[Phase A Actual Amps]>0) And ([M].[Phase B Actual Amps]>0) And ([M].[Phase C Actual Amps]=0),([Phase A Actual Amps]+[Phase B Actual Amps])/2,IIf(([M].[Phase A Actual Amps]>0) And ([M].[Phase B Actual Amps]=0) And ([M].[Phase C Actual Amps]=0),([Phase A Actual Amps]),IIf(([M].[Phase A Actual Amps]=0) And ([M].[Phase B Actual Amps]>0) And ([M].[Phase C Actual Amps]=0),([Phase B Actual Amps]),IIf(([M].[Phase A Actual Amps]=0) And ([M].[Phase B Actual Amps]=0) And ([M].[Phase C Actual Amps]>0),([Phase C Actual Amps]),0)))))))

Thanks,

Rick

Reply to this topic

Message
Reply
Follow us on Facebook Follow us on twitter Subscribe to the RSS feed
Activate your free membership today | Login | Currency