Hello, just need some help with a few MS-SQL queries. I asked these questions recently and recieved multiple errors when trying them out.
Questions:



Previous answer to Task 2 that didnt work:




It would have been easy if you could have shared the DB details also. Anyway, For TASK 2: you can use the following query
UPDATE Customers set TotalVisits=(select count(CustomerID)
from CustomerVisits where
Customers.CustomerID=Customervisits.CustomerID group by
CustomerID);
I have tested the query on a different database and it is working as you want.
Task 4: Trigger should work something like this:
It needs to automatically update the customers totalvisits column on the basis an update,delete and insertion.
You should look for spelling mistakes if any in the below code because we can't test without the DB here.
create or replace trigger total_visits on
CustomerVisits
after INSERT or DELETE or UPDATE as
begin
UPDATE Customers set TotalVisits=(select count(CustomerID)
from CustomerVisits where
Customers.CustomerID=customervisits.CustomerID
group by CustomerID);
end;
/
Similarly, Task for totalspent can be completed.
Hello, just need some help with a few MS-SQL queries. I asked these questions recently and...
Using the database: Write SQL queries for each of the questions
below.
1. Find the media type which
has 100 or more tracks. Print the name of such media type. Number
of rows returned in the result = 3
A) Find the playlists which have one or more tracks that have
never been purchased in California (CA). Print the Id, and the name
of such playlists. Number of rows returned in the result = 18
B) Find the customers who...
Hello, I need help answering all 8 of these questions for my BIS
422 class. I need the appropriate MySQL script to use for these
questions
Provide the SQL for the following data requests. Your SQL should
be written as a single script that can be pasted into MySQL and run
without edits. Make sure you use the proper notation for your
comments (see the practice solution for an example of the format).
There will be a 5% deduction for...
Hi, I'm trying to do my
homework for my SQL Server class I keep getting stuck on the
questions 1-5 I found out like how the format need to be
I'm just stuck on implanting the code in.
Auntie B's Antic ERD CUSTOMER OWNER PEOPLE PeoplelD CustomerSince CHARITY Peopleld FirstName LastName Address City State Zip Phone CellPhone EMail PeopleType CharityID Name Address City State WORKERS PeoplelD HireDate TermDate SSN ip Phone ContactID ORDERS OrderlD OrderDate CustomerlD EmployeelD DONATION DonationID DonationDate...