Hi, I am trying to solve the following question : Write a script that counts the number of books that have been ordered by at least one customer from California. Count each individual title only once, even if more than one CA customers has ordered it. The output should say "Number of titles that have been ordered from CA: 42", with the correct value in place of 42.
Table 1 = tblorders
Table 2 = tblcustomers
They have custid as a common table. Any idea?
DECLARE @B int;
SET @B = (SELECT COUNT(*)
FROM tblbooks bo JOIN tblcustomers c ON bo.custid = c.custid
WHERE custstat = 'CA');
IF @B count > 0
Print 'Number of titles that have been ordered from CA: + CAST @B AS VARCAR(64)'
Print'There are not any books ordered'