Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help converting Cross Tab to SQL form

Status
Not open for further replies.

mxfrail

MIS
Jul 7, 2008
25
0
0
US
I am trying to convert this into SQL form -

TRANSFORM count(tblinserts.clientid) AS SumOfHomes
SELECT tblInserts.SalesRep, tblstaff.firstname, tblstaff.lastname
FROM tblInserts, tblstaff
WHERE tblinserts.inserttype<>'W' and tblinserts.salesrep=tblstaff.repid
GROUP BY tblInserts.SalesRep, tblstaff.lastname, tblstaff.firstname
PIVOT Format([ProductionDate],"mmm") In ("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");


The reason why I need to do this is because I need to beable to get a distinct count off the clientid I am counting.

Any help would be appreciated.
 
Thats in access SQL but it will not obviously run from SQL 2000 directly because not until SQL 2005 is PIVOT really an option.
 
Have a look at the CASE expression.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top