Oh, my misunderstanding. I thought you meant to post/issue on the website a request of discussion.
Anyway... here I provide a simple example to clarify what I mean:
I would like to create a stored procedure, something like that:
CREATE PROCEDURE p_employee
(
IN custID INT
)
SELECT si.invoiceID, si.customerID,
sd.ProductID, sd.Quantity,
cp.ProductName,cp.RetailPrice
FROM SalesInvoice as si
JOIN SalesInvoiceDetail AS sd ON si.InvoiceID=sd.InvoiceID
JOIN CurrentProducts AS cp ON cp.ProductsID=sp.ProductsID
WHERE si.CustomerID=custID
if I wanted to run the procedure I'd have to type as follows:
CALL p_employee(x)
where "x" would be the input parameter custID,corresponding to the ID of a specific customer for whom I want to know the output informations.
But what if I wanted to execute the stored procedure for 10000 customers simultaneously?
Literature includes one function named "cross apply" through which I could pass as input parameter ("x") one entire column, extracted from another table.
SELECT *
FROM customer AS cu CROSS APPLY p_employee(cu.CustomerID)
ORDER BY cu.CustomerID
WHERE cu.Income >= (select median(Income) from cu)
The issue is all about the "CROSS APPLY" function which in 9.3.0.4984 HeidiSQL version is not included, as well as the "median" function or a "quantile" functions to compute continuous or descrete distribution quantiles. In fact, if I type those functions in my sql sheet they won't be recognized as functions and the code will return errors accordingly.
Any suggestion on how to execute the functions reported likewise?
Thank you in advance