GrunleStan
Registered User.
- Local time
- Today, 16:58
- Joined
- Aug 7, 2018
- Messages
- 22
All suggestions readily accepted.
So background. I have a HR database that has to be hosted on a whole bunch of Sharepoint List.
Each branch staff & private staff information has to be in a separate table/List. We can't have branch looking into other branch. So to join all of them into 1 table I use a UNION.
The staff grades/ designation/ additional appointments & etc is stored separately..
Doing this so we can keep track of historical data;
eg who was the Fire Warden in 2015 and such. So & so was promoted to Lab Assistant Lvl 2 on 6-Jul-2016.
So for the Subgrade ( pay grade ); designation, PAA & SAA fields, only the Latest of these are only picked out....
For these I use a MaxD aggregate which will filter only the latest record for each Staff.
SQL is as such...
my current get-all-the-data-together query uses the following
The Query works but is painfully slow. even when the data is directly on the same machines.
Is there anything I can do to speed up queries?
If this query was ran for a form, then user switched to another form, will this same query be run again ?
The Zip file is a jpg of the design view of the Main SQL query.
TIA everyone.
So background. I have a HR database that has to be hosted on a whole bunch of Sharepoint List.
Each branch staff & private staff information has to be in a separate table/List. We can't have branch looking into other branch. So to join all of them into 1 table I use a UNION.
Code:
SELECT * FROM tbl_Staff_Branch1
UNION ALL
SELECT * FROM tbl_Staff_Branch2
UNION ALL ......
SELECT * FROM tbl_Staff_Branch7
UNION ALL SELECT * FROM tbl_Staff_HQAdmin;
The staff grades/ designation/ additional appointments & etc is stored separately..
Doing this so we can keep track of historical data;
eg who was the Fire Warden in 2015 and such. So & so was promoted to Lab Assistant Lvl 2 on 6-Jul-2016.
So for the Subgrade ( pay grade ); designation, PAA & SAA fields, only the Latest of these are only picked out....
For these I use a MaxD aggregate which will filter only the latest record for each Staff.
SQL is as such...
Code:
SELECT tbl_Dsgn.*
FROM tbl_Dsgn
WHERE (((tbl_Dsgn.DA_DateAssign)=DMax("DA_DateAssign","tbl_Dsgn","DA_Staff_ID=" & "'" & [DA_Staff_ID] & "'")));
my current get-all-the-data-together query uses the following
Code:
SELECT qryAllStaff.*, qryAllSP.*, qryDsgnMaxD.*, qryPAAMaxD.*, qrySAAMaxD.*, qrySubGMaxD.*, [S_Salute] & ". " & [S_NAME] AS CombinedName
FROM ((((qryAllStaff LEFT JOIN qryDsgnMaxD ON qryAllStaff.S_NRIC = qryDsgnMaxD.DA_Staff_ID) LEFT JOIN qryPAAMaxD ON qryAllStaff.S_NRIC = qryPAAMaxD.PAA_Staff_ID) LEFT JOIN qrySAAMaxD ON qryAllStaff.S_NRIC = qrySAAMaxD.SAA_Staff_ID) LEFT JOIN qryAllSP ON qryAllStaff.S_NRIC = qryAllSP.SP_NRIC) LEFT JOIN qrySubGMaxD ON qryAllStaff.S_NRIC = qrySubGMaxD.subG_NRIC;
The Query works but is painfully slow. even when the data is directly on the same machines.
Is there anything I can do to speed up queries?
If this query was ran for a form, then user switched to another form, will this same query be run again ?
The Zip file is a jpg of the design view of the Main SQL query.
TIA everyone.