Help with SQL Statement for pivot table

G

Guest

I'm trying to put a sql statment from an access query into a pivot table
query builder. I built the query in access then took the sql view and tried
to put it into the excel query builder -- not working.

Access put dbo_ in front of all of the table names so I took that out but
it's got other problems too. Not sure how the date range should be specified
and I wanted it to search a text field for the word "implant". In access I
did this by specifying *implant* but sql doesn't seem to like it.

Here's the statement:
SELECT ApptPending.CreateDate, ApptPending.ApptPendingID,
ApptPending.OfficeID, ApptPending.ProviderID
FROM ApptPending
WHERE (((ApptPending.PendingSource)=0) AND ((ApptPending.ApptTypeID)=6 Or
(ApptPending.ApptTypeID)=16)) OR (((ApptPending.ApptNote) Like "*implant*"))
GROUP BY ApptPending.CreateDate, ApptPending.ApptPendingID,
ApptPending.OfficeID, ApptPending.ProviderID
HAVING (((ApptPending.CreateDate)<=#3/16/2006#));
 
M

MH

Try iy using % instead of *

MS Query supports the ANSII standard sql wildcards but Access (using Jet as
the back end) does not.

MH
 
G

Guest

Started from scratch from withing query builder and solved most problems.
What I want is for it to select out any records with an appttype of 6 or 16
OR the word implant in the apptnote field. But it will not let me add the
apptnote field to the groupby list for some reason. Here's the new sql
statement. The field I want added is apptpending.apptnote

SELECT ApptPending.CreateDate, ApptPending.ApptPendingID,
ApptPending.OfficeID, ApptPending.ProviderID, ApptPending.OfficeID,
ApptPending.ProviderID, ApptPending.RefSourceID
FROM DWare.dbo.ApptPending ApptPending
WHERE (ApptPending.PendingSource=0) AND (ApptPending.ApptTypeID=6) OR
(ApptPending.ApptTypeID=16)
GROUP BY ApptPending.CreateDate, ApptPending.ApptPendingID,
ApptPending.OfficeID, ApptPending.ProviderID, ApptPending.OfficeID,
ApptPending.ProviderID, ApptPending.RefSourceID
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top