|
LinuxGold
Starting Member
3 Posts |
Posted - 2005-05-03 : 15:51:19
|
| Since I'm learning about Left joins and am trying to figure out a wayto quickly gather info from Database all at once, here is the SQLstatement. Please give me feedback how I should improve it for betterperformance. There are around 10 users that will hit database likethis along with other left joins ever minute. Thanks in advance:SELECT QA.ID, Brands.Brand, QA.KeyDate, A2.LastName + ', ' + A2.FirstName as Reviewer, A1.LastName + ', ' + A1.FirstName as Operator, Batch.[order], Errortypes.[Description], ErrorTypes.points, Batch.Comments, (SELECT sum(Errortypes.points) FROM ErrorTypes,QAErrors,Batch,QA WHERE Errortypes.Id=QAErrors.ErrorTypeID AND QAErrors.ID=Batch.QEID AND Batch.QAID=QA.ID AND QA.Batch='464005807') as points, (SELECT count(*)*100 FROM Batch,QA WHERE Batch.QAID=QA.ID AND QA.Batch='464005807') as totalFROM Brands,Associates A1, Associates A2,QALeft Join Batch ON Batch.QAID=QA.IDLeft Join QAErrors ON QAErrors.ID=Batch.QEIDLeft Join Errortypes On ErrorTypes.id=QAErrors.ErrorTypeIDWHERE QA.Batch='464005807'AND A1.ID=QA.OperatorIDAND A2.ID=QA.QAIDAND Brands.ID=QA.BrandID;RESULT (delimited by ,):100528,Imaged G-5,2005-05-03 00:00:00,Cahall, Margaret,Custis,Teresa,244770323,Error in Name,8.0,last name mispelled,24.0,600100528,Imaged G-5,2005-05-03 00:00:00,Cahall, Margaret,Custis,Teresa,244770323,Error in Address,8.0,blvd mispelled,24.0,600100528,Imaged G-5,2005-05-03 00:00:00,Cahall, Margaret,Custis,Teresa,244770324,Error in Address,8.0,BLVD MISSPELLED,24.0,600100528,Imaged G-5,2005-05-03 00:00:00,Cahall, Margaret,Custis,Teresa,244770325,NULL,NULL,NULL,24.0,600100528,Imaged G-5,2005-05-03 00:00:00,Cahall, Margaret,Custis,Teresa,244770322,NULL,NULL,NULL,24.0,600100528,Imaged G-5,2005-05-03 00:00:00,Cahall, Margaret,Custis,Teresa,244770321,NULL,NULL,NULL,24.0,600Power to people, Linux is here. |
|