Please help on this one:

SELECT Format([expr1],"# %") AS expr2, totvisit/totrem AS expr1 
FROM   ( 
          SELECT Count(*) AS totrem 
          FROM   ( 
                                 SELECT DISTINCT remid 
                                 FROM            remtable 
                                 WHERE           remtable.pacid = 94) AS r, 
                 ( 
                        SELECT Count(*) AS totvisit 
                        FROM   ( 
                                               SELECT DISTINCT visitaid 
                                               FROM            jurnal 
                                               WHERE           jurnal.pacient_id = 94) AS b

Which give me this:
Msg 102, Level 15, State 1, Line 15
Incorrect syntax near 'b'.

I'm not very sure of what you're trying, but perhaps:

SELECT Format([expr1],"# %") AS expr2, count(totvisit)/count(totrem) AS expr1 
FROM (   
            SELECT DISTINCT remid 
            FROM            remtable
            WHERE           remtable.pacid = 94) AS totrem,
     ( 
            SELECT DISTINCT visitaid
            FROM            jurnal  AS b
            WHERE           jurnal.pacient_id = 94) AS totvisit
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.