Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I have the following Script:
When i load the above script i get an OLEDB Read Failed error message. What is wrong in the Script?
SQL Select
Branch,[Retail Pharmacy],[Script Number],
Count(Distinct [Script Number]) as Rx
from PharmaMarketAudit.dbo.tblDatawarehouseConsolodatedCleanStage
Group By
Branch,
[Retail Pharmacy],
[Script Number];
Hi Christopher,
[Script Number] field there is not in the Group By
Regards,
Antonio
Try with a resident load than a preceeding load
Temp:
SQL Select Branch,
"Retail Pharmacy",
"Script Number"
From PharmaMarketAudit.dbo.tblDatawarehouseConsolodatedCleanStage;
Noconcatenate Load
Branch,
[Retail Pharmacy],
[Script Number]
Count(Distinct [Script Number]) as Rx
Resident Temp
Group By
Branch,
[Retail Pharmacy],
[Script Number];
Drop Table Temp;
Hi Christopher,
Do not use aggregation directly while loading the data. Probably it should be the reason for you to get the error.
First load the data and then use resident load while doing aggregation. Sasidhar has given the script in this thread. It should work for you to resolve the issue.
-GDK
Noted with thanks Antonio. However the script takes forever to execute and i am having to force it to end
Thank you Sasidhar. After loading the temp table, the script takes forever to execute the resident load and i am having to force it to quit without ending the script execution
Thanks Gowtham, please see my responses above
I did a distinct SQL SELECT in the temp table load and a straight count in the resident load to reduce the amount of memory use
Christopher,
move Group by from LOAD to Select
This should be faster..
SQL Select
Branch,[Retail Pharmacy],[Script Number],
Count(Distinct [Script Number]) as Rx
Group By
Branch,
[Retail Pharmacy],
[Script Number]
from PharmaMarketAudit.dbo.tblDatawarehouseConsolodatedCleanStage ;
However, if You Group By [Script Number] then Count(Distinct [Script Number]) is always 1.
Perhaps remove DISTINCT from Count or remove [Script Number] from Select Fields List and from Group By.
as per me here group by is issue....
Please remove group by and load ..then take resident and then aggr value. else aggr in sql script don't agg in preceding load.