• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 251
  • Last Modified:

Access Conversion to SQL

What is the correct SQL syntax for the SQL statement below

SELECT dbo_jobroute.jobid, dbo_jobroute.routeindex, Max(IIf(([routetypeid] In (1,2) And [pcpe]=""),1,0)) AS [Received Without], Max(IIf(([routetypeid] In (1,2) And [pcpe]<>""),1,0)) AS [Received With], Max(IIf(([routetypeid]=3 And [pcpe]=""),1,0)) AS [Sent Without], Max(IIf(([routetypeid]=3 And [pcpe]<>""),1,0)) AS [Sent With]
FROM dbo_jobroute INNER JOIN dbo_routing ON dbo_jobroute.routingid = dbo_routing.routingid
GROUP BY dbo_jobroute.jobid, dbo_jobroute.routeindex;

Thanks

Poly
0
polynominal
Asked:
polynominal
  • 2
1 Solution
 
Steve BinkCommented:
That looks fine.  Is it not working?
0
 
rafranciscoCommented:
SELECT dbo_jobroute.jobid, dbo_jobroute.routeindex,
       MAX(CASE WHEN [routetypeid] In (1,2) And [pcpe]=''  THEN 1 ELSE 0 END) AS [Received Without],
       MAX(CASE WHEN [routetypeid] In (1,2) And [pcpe]<>'' THEN 1 ELSE 0 END) AS [Received With],
       MAX(CASE WHEN [routetypeid]=3 And [pcpe]='' THEN 1 ELSE 0 END) AS [Sent Without],
       MAX(CASE WHEN [routetypeid]=3 And [pcpe]<>'' THEN 1 ELSE 0 END) AS [Sent With]
FROM dbo_jobroute INNER JOIN dbo_routing ON dbo_jobroute.routingid = dbo_routing.routingid
GROUP BY dbo_jobroute.jobid, dbo_jobroute.routeindex;
0
 
Steve BinkCommented:
der...MSSQL, not Access.  I get it now...LOL
0

Featured Post

Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now