Suppose that we have a table and save on it customerid and orderid.
What is the best approach for take count of all order and check exist of certain customerid in one query ?
I know that this query is wrong but I forced write that because Stackoverflow did not allow me post short question!
For example :
(table name tbTest)
SELECT
COUNT(ORDERID),
EXIST(SELECT ID FROM tbTest WHERE customerid = {n})
FROM tbTest
Please try with the follwoing