Results 1 to 2 of 2
  1. #1
    oorja is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2011
    Posts
    1

    sql query to access query

    I have a query in sqlserver that works perfectly well.
    It contains case statement which is missing in access and i have read that it
    can be suitably work using IIF.
    Can some nice soul come ahead help me with coding the following query so that it works in access/
    Thanks

    Select distinct a.acctid,b.acctid,a.acctname,c.location,c.location id,openingBalance = Convert(Money,SUM(
    CASE TransType


    WHEN 1 THEN TransAmt
    WHEN 0 THEN (TransAmt * -1)
    ELSE TransAmt
    END) )
    From Trans b
    inner join accounts a on a.acctid = b.acctid
    left join locations c on a.locationid = c.locationid
    where 1= 1
    group by a.acctid,b.acctid,a.acctname,c.location,c.location id

  2. #2
    NoellaG's Avatar
    NoellaG is offline VIP
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Jun 2010
    Location
    Belgium
    Posts
    1,173
    Hi,

    the case instruction can be substituted by :

    Iif([TransType] = 1,[Transamt],-[Transamt])

    The Iif function has the syntax:
    Iif(Logical Test,value If true, value if false)

    You can easily find the syntaxes of Acces functions using HELP

    succes
    NG

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Access TOP VALUE in query
    By Carpy01 in forum Queries
    Replies: 8
    Last Post: 07-13-2012, 01:01 PM
  2. New to access and need help with query
    By zero3ree in forum Access
    Replies: 1
    Last Post: 02-12-2010, 05:03 AM
  3. Access Query
    By malaysarkar in forum Queries
    Replies: 0
    Last Post: 11-26-2009, 12:57 PM
  4. Sql server query to MS access query
    By blazixinfo@yahoo.com in forum Queries
    Replies: 0
    Last Post: 07-07-2009, 08:12 AM
  5. Access Query
    By LinneaUD13 in forum Queries
    Replies: 0
    Last Post: 06-05-2009, 03:46 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums