sql server - vba error - SQL left join issue -
i trying solve issue , sql , vba, thought post here. error shows left join issue, not sure if false flag.
strsql = "select userid userid,appointmentdate, isnull ([1],0) as'other',isnull ([2],0) 'medicare'" & _ "from (select invoices.userid, appointmentdate," & _ "[total] , payercode, users.locationid" & _ "from appointments " & _ "left join invoices on recordid = appointmentid inner join users on appointments.userid = users.userid" & _ "where appointmentdate between '2017-01-22' , '2017-01-22' " & _ "and invoices.internalid >0 " & _ "and appointments.recordstatus in (1,3,4) " & _ "and not appointments.internalid = 0 " & _ "and not consultationtime = 0 " & _ "and arrivaltime >0 " & _ "and appointmentid not '' " & _ ") sourcetable " & _ "pivot " & _ "( " & _ "sum (total) " & _ "for payercode in ([1], [2]) " & _ ") pivottable; "
i have number of standard select sql queries working in excel file, pivot causing challenge.
as normal ms error limited - sorry lack of crystal balls.. error says - run-time error '-2147217900 (80040e14)': incorrect syntax near keyword 'left' cheers
there no space after locationid
, result of this
"[total] , payercode, users.locationid" & _ "from appointments " & _ "left join ..."
is this:
[total] , payercode, users.locationidfrom appointments left join ...
so have botched from
, causing left
not understood or expected @ position.
Comments
Post a Comment