Question

In the movies database and actor table, label all values in the last_name field that start...

In the movies database and actor table, label all values in the last_name field that start with a, b or c as "A,B,C start" or "Other" and name it LastName, and do the same with all the values in the first_name field and name it FirstName. Group by FirstName and LastName, and return the count as total but only return grouping where the FirstName and the Lastname are equal. Order by total desc.

Homework Answers

Answer #1
SELECT
     CASE
        WHEN LEFT(last_name, 1) = "a" THEN "A start"
        WHEN LEFT(last_name, 1) = "b" THEN "B start"
        WHEN LEFT(last_name, 1) = "c" THEN "C start"
        ELSE "Other"
      END AS LASTNAME,
      CASE
        WHEN LEFT(first_name, 1) = "a" THEN "A start"
        WHEN LEFT(first_name, 1) = "b" THEN "B start"
        WHEN LEFT(first_name, 1) = "c" THEN "C start"
        ELSE "Other"
      END AS FIRSTNAME,
      COUNT(1)
FROM
    movies.ActorsTable
WHERE LASTNAME = FIRSTNAME
GROUP BY FIRSTNAME,LASTNAME
ORDER BY DESC
Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
EMPLOYEE Field Name EMP_ID EMP_LNAME EMP_MI EMP_FNAME EMP_SEX EMP_AGE EMP_SALARY EMP_HIREDATE DEPT_CODE Table: DEPARTMENT DEPT_CODE BIOL...
EMPLOYEE Field Name EMP_ID EMP_LNAME EMP_MI EMP_FNAME EMP_SEX EMP_AGE EMP_SALARY EMP_HIREDATE DEPT_CODE Table: DEPARTMENT DEPT_CODE BIOL CPTR HIST MATH RELB Data Type Text Text Text Text Text Number Currency Date/Time Text DEPT_TITLE Biology Computer Science History Mathematics Religion    Field Name DEPT_CODE DEPT_TITLE Data Type Text Text INSTRUCTIONS Use SQL commands to create the tables and enter the data shown above using MS Access. Write the following SQL statement given below: 1. 2. 3. 4. 5. 6. 7. 8. 9....
QUESTION 5 The ACCOUNT table contains these columns: ACCOUNT_ID NUMBER(12) NEW_BALANCE NUMBER(7,2) PREV_BALANCE NUMBER(7,2) FINANCE_CHARGE NUMBER(7,2)...
QUESTION 5 The ACCOUNT table contains these columns: ACCOUNT_ID NUMBER(12) NEW_BALANCE NUMBER(7,2) PREV_BALANCE NUMBER(7,2) FINANCE_CHARGE NUMBER(7,2) You must create statements to be mailed to all account holders. Each customer's statement must include the account holder's previous balance and finance charge (0.09 of previous balance) in this format: Previous Balance:   5000 &  Finance Charge: 45 Which SELECT statement will produce these results? A. SELECT Previous Balance: || prev_balance || & Finance Charge: || prev_balance * .009   FROM account; B. SELECT 'Previous Balance:'...
The relational schema for the Academics database is as follows: DEPARTMENT(deptnum, descrip, instname, deptname, state, postcode)...
The relational schema for the Academics database is as follows: DEPARTMENT(deptnum, descrip, instname, deptname, state, postcode) ACADEMIC(acnum, deptnum*, famname, givename, initials, title) PAPER(panum, title) AUTHOR(panum*, acnum*) FIELD(fieldnum, id, title) INTEREST(fieldnum*, acnum*, descrip) Some notes on the Academics database: An academic department belongs to one institution (instname) and often has many academics. An academic only works for one department. Research papers (PAPER) are often authored by several academics, and of course an academic often writes several papers (AUTHOR). A research field...
Garden Glory Project Questions Assume that Garden Glory designs a database with the following tables: OWNER...
Garden Glory Project Questions Assume that Garden Glory designs a database with the following tables: OWNER (OwnerID, OwnerName, OwnerEmail, OwnerType) OWNED_PROPERTY (PropertyID, PropertyName, PropertyType, Street, City, State, Zip, OwnerID) GG_SERVICE (ServiceID, ServiceDescription, CostPerHour); EMPLOYEE (EmployeeID, LastName, FirstName, CellPhone, ExperienceLevel) PROPERTY_SERVICE ( PropertyServiceID , PropertyID , ServiceID, ServiceDate , EmployeeID, HoursWorked) The referential integrity constraints are: OwnerID in OWNED_PROPERTY must exist in OwnerID in OWNER PropertyID in PROPERTY_SERVICE must exist in PropertyID in OWNED_PROPERTY ServiceID in PROPERTY_SERVICE must exist in ServiceID...
Which query lists all products with a total quantity sold less than the average quantity sold?...
Which query lists all products with a total quantity sold less than the average quantity sold? Select one: a. SELECT P_CODE, SUM(LINE_UNITS) AS TOTALUNITS FROM LINE GROUP BY P_CODE HAVING SUM(LINE_UNITS) < AVG(LINE_UNITS); b. SELECT P_CODE, AVG(LINE_UNITS) AS TOTALUNITS FROM LINE GROUP BY P_CODE HAVING AVG(LINE_UNITS) < (SELECT AVG(LINE_UNITS) FROM LINE); c. SELECT P_CODE, SUM(LINE_UNITS) AS TOTALUNITS FROM LINE GROUP BY P_CODE HAVING SUM(LINE_UNITS) < (SELECT AVG(LINE_UNITS) FROM LINE); d. SELECT P_CODE, SUM(LINE_UNITS) AS TOTALUNITS FROM LINE GROUP BY P_CODE...
Summary The Ch08_ConstructCo database stores data for a consulting company that tracks all charges to projects....
Summary The Ch08_ConstructCo database stores data for a consulting company that tracks all charges to projects. The charges are based on the hours each employee works on each project. The structure and contents of the Ch08_ConstructCo database are shown in Figure P8.1. Use this database to answer the following problems. Database Schema The schema for the Ch08_ConstructCo database is shown below and should be used to answer the next several problems. Click this image to view it in its own...
InstantRide is the new ride sharing application in the city and it has just started its...
InstantRide is the new ride sharing application in the city and it has just started its operations. With the help of the InstantRide mobile application, the users request a ride with their location. Drivers and cars are assigned to the request; and then the driver picks up the user to ride their requested location. Information for the users, drivers and cars are stored in the database as well as the travel transactions. In the USERS table, information for the users...
Complete a Java program named ARMgr that maintains customer accounts receivable in a database. The code...
Complete a Java program named ARMgr that maintains customer accounts receivable in a database. The code to initialize the CustomerAccountsDB database table and add a set of customer accounts is provided. Finish the code in these 3 methods in CustomerAccountDB.java to update or query the database: -purchase(double amountOfPurchase) -payment(double amountOfPayment) -getCustomerName() Hint: For getCustomerName(), look at the getAccountBalance() method to see an example of querying data from the database. For the purchase() and payment() methods, look at the addCustomerAccount() method...
Record the data. In class, randomly pick one person. On the class list, mark that person’s...
Record the data. In class, randomly pick one person. On the class list, mark that person’s name. Move down four names on the class list. Mark that person’s name. Continue doing this until you have marked 12 names. You may need to go back to the start of the list. For each marked name record the five data values. You now have a total of 60 data values. For each name marked, record the data. 5 3 0 0 0...
Consider the One-Way ANOVA table (some values are intentionally left blank) for the amount of food...
Consider the One-Way ANOVA table (some values are intentionally left blank) for the amount of food (kidney, shrimp, chicken liver, salmon and beef) consumed by 50 randomly assigned cats (10 per group) in a 10-minute time interval. H0: All the 5 population means are equal   H1: At least one population mean is different. Population: 1 = Kidney, 2 = Shrimp, 3 = Chicken Liver, 4 = Salmon, 5 = Beef. ANOVA Source of Variation SS df MS F P-value F...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT