Question

MySQL

SELECT
   DWTIME.TM_MONTH AS TM_MONTH,
   DWSALESFACT.SALE_UNITS AS NUMPROD,
   SUM(DWSALESFACT.SALE_PRICE*DWSALESFACT.SALE_UNITS) AS TOTSALES
FROM DWSALESFACT INNER JOIN DWTIME
ON
DWSALESFACT.TM_ID=DWTIME.TM_ID
GROUP BY
DWTIME.TM_MONTH WITH ROLLUP;TM_MONTH NUMPROD TOTSALES 9 23 1239.85 10 13 1012.21 NULL 36 2252.06

ERROR 1055 (42000) at line 2: Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'Ch13_SaleCo.DWSALESFACT.SALE_UNITS' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

What am i missing???

0 0
Add a comment Improve this question Transcribed image text
Answer #1

ANSWER

Hi this can be easly solve by changing the sql_mode value. Mysql server can operate different sql_mode. sql_mode is system varaiable. We can change with our operating requirments. We can see the values of our system sql_mode using following query

select @@sql_mode;

My system setting is as follows.

MariaDB [amith]> select @asql_mode; | casql_mode | STRICT_TRANS_TABLES , ERROR_FOR_DIVISION_BY_ZERO, NO_AUTO_CREATE_USER, NO_

For change this sql_mode at runtime, set the global or session sql_mode system variable using a SET statement

SET GLOBAL sql_mode = 'modes';
SET SESSION sql_mode = 'modes';

we can use the different modes in modes section. In the above figure shows the default modes.

To resolve your issue please set sql_mode with 'ONLY_FULL_GROUP_BY'

SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));

or

SET GLOBAL sql_mode = 'ONLY_FULL_GROUP_BY';
 

Any doubts please comment and upvote too...

Thanks in advance

Add a comment
Know the answer?
Add Answer to:
MySQL SELECT    DWTIME.TM_MONTH AS TM_MONTH,    DWSALESFACT.SALE_UNITS AS NUMPROD,    SUM(DWSALESFACT.SALE_PRICE*DWSALESFACT.SALE_UNITS) AS TOTSALES FROM DWSALESFACT...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Summarize these pages in your own style and you have to include in your report some...

    Summarize these pages in your own style and you have to include in your report some figures highlighting the relation between these operations. Basic AGGREGATE functions (Revision) COUNT: returns the number of tuples, which meet the specified condition: SELECT COUNT(DISTINCT Dept) AS Num_Depts FROM subject: SUM: returns the sum of the values in a specified column (i.e. numeric column) SELECT COUNT(*) AS hi_sal, SUM(salary) FROM Lecturer WHERE Salary > 4500 MIN: returns the minimum value in a specified column (numeri...

  • SQL help I am using livesql.oracle This is CTE I created for problem 4 SELECT CUST_LAST_NAME,...

    SQL help I am using livesql.oracle This is CTE I created for problem 4 SELECT CUST_LAST_NAME, CUST_EMAIL, ORDER_ID, SUM(QUANTITY) AS QTY FROM (SELECT CUST_LAST_NAME, CUST_EMAIL, ORDERS.ORDER_ID, PRODUCT_ID, QUANTITY FROM OE.CUSTOMERS INNER JOIN OE.ORDERS ON OE.CUSTOMERS.CUSTOMER_ID = OE.ORDERS.CUSTOMER_ID INNER JOIN OE.ORDER_ITEMS ON OE.ORDERS.ORDER_ID = OE.ORDER_ITEMS.ORDER_ID ORDER BY ORDER_ID ASC) CTE GROUP BY CUST_LAST_NAME, CUST_EMAIL, ORDER_ID; 5. Using the CTE named customer_information that you created for the previous problem (problem 4). Add a correlated subquery that also shows the total value of...

  • #6 Write a SELECT statement that returns these columns: The count of the number of orders...

    #6 Write a SELECT statement that returns these columns: The count of the number of orders in the Orders table The sum of the tax_amount columns in the Orders table Write a SELECT statement that returns one row for each category that has products with these columns: The category_name column from the Categories table The count of the products in the Products table The list price of the most expensive product in the Products table Sort the result set so...

  • Using mySQL, tables at the end... This assignment uses the tables from the vets database. The goa...

    Using mySQL, tables at the end... This assignment uses the tables from the vets database. The goal of the assignment is to get you to think about joins- inner join and outer joins.  If you do a join, where you have the names of two or more tables in the From clause, then you must use the condition join syntax or the column name join. Take care that you do not accidentally do a Cartesian product. If your result set...

  • QUERY EXAMPLE2 SELECTfrom Employee em (Refer to query example 2 to answer questions 12- 13) 12....

    QUERY EXAMPLE2 SELECTfrom Employee em (Refer to query example 2 to answer questions 12- 13) 12. You plan to join the Location table and fear there may be some employees with no location. You want to make sure that the query returns a list of all employee What join clause would you add to the query above? records. A. LEFT JOIN Location lo ON em.LocationlD lo LocationID B. RIGHT JOIN Location lo ON em.LocationID lo.LocationlD C. INNER JOIN Location lo...

  • Which SQL statement retrieves the EmployeeName and City columns from the Employees table? O LIST EmployeeName,...

    Which SQL statement retrieves the EmployeeName and City columns from the Employees table? O LIST EmployeeName, City ON Employees; O FIND EmployeeName, City ON Employees; SELECT EmployeeName, City FROM Employees; O RETRIEVE EmployeeName, City FROM Employees; Which SQL statement finds the different cities in which national parks reside with no duplicate rows listed? SELECT DISTINCT city FROM natlpark ORDER BY city; O ORDER BY natlpark DISTINCT city; O ORDER BY city FROM natlpark; O SELECT city FROM natlpark ORDER BY...

  • 5. Write a SELECT statement that returns these columns from the Orders table: OrderID OrderDate ShipDate...

    5. Write a SELECT statement that returns these columns from the Orders table: OrderID OrderDate ShipDate Return only the rows where the ShipDate column contains a null value. 6. Write a SELECT statement that returns all columns from the Addresses table State is equal to CA 7. Write a SELECT statement that returns all columns from the Products table Product name has a "ru" in its name 8. Write a SELECT statement that returns these columns from the Customers table...

  • (a) Load the data file data/tips.csv into a pandas DataFrame called tips_df using the pandas read_table()...

    (a) Load the data file data/tips.csv into a pandas DataFrame called tips_df using the pandas read_table() function. Check the first five rows. (b) Create a new dataframe called tips by randomly sampling 6 records from the dataframe tips_df. Refer to the sample() function documentation. (c) Add a new column to tips called idx as a list ['one', 'two', 'three', 'four', 'five', 'six'] and then later assign it as the index of tips dataframe. Display the dataframe. (d) Create a new...

  • I need help with certain questions. Please. 18. 4 points For each Rental, list the Rental...

    I need help with certain questions. Please. 18. 4 points For each Rental, list the Rental ID, Rental date, customer ID, customer first name, customer last name, and count of disks rented; sort by Rental ID. Show the Rental date formatted as ‘mm-dd-yyyy.’ Hint: use a GROUP BY clause. 19. 4 points List the disk ID, title name, rating, format description, and fee amount for all copies rented in Rental 3; sort by disk ID. Show the fee amount formatted...

  • 11. For each song in the songs table, update the value of artist_id to the id...

    11. For each song in the songs table, update the value of artist_id to the id of the corresponding artist in the artists table. 11.1. You must update all songs using only one UPDATE statement and a subquery. Hardcoded ids or names are not allowed in your query. 12. For each song in the songs table, update the value of genre_id to the id of the corresponding genre in the genres table. 12.1. You must update all songs using only...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT