group-by

SQL error: 'database.table.field isn't in GROUP BY

↘锁芯ラ 提交于 2019-12-25 04:47:25
问题 I am getting this when I am installing a 3rd party software. I've read the related topics and all of them suggested to set sql_mode to an empty string ( SET sql_mode = '' ) but that solution didn't work for me. Still getting the same error. Do I need to set this in my config file or something? Here's some useful info; Server version: 5.6.15-56-log Percona Server (GPL), Release rel63.0, Revision 519 mysql> SHOW VARIABLES LIKE 'sql_mode'; +---------------+-------+ | Variable_name | Value | +---

sql group by and max and other values

二次信任 提交于 2019-12-25 04:27:38
问题 i have a table that contains: itemid inventdimid datephysical transrefid 10001 123 2015-01-02 300002 10002 123 2015-01-03 3566 10001 123 2015-02-05 55555 10002 124 2015-02-01 4545 The result i want itemid inventdimid datephysical transrefid 10001 123 2015-02-05 555 10002 123 2015-01-03 3566 10002 124 2015-02-01 4545 MY query: SELECT a.itemid,a.inventdimid,max(a.datephysical),a.transrefid FROM a where dataareaid = 'ermi' group by a.itemid,a.inventdimid it is invalid in the select list because

sql group by and max and other values

倾然丶 夕夏残阳落幕 提交于 2019-12-25 04:27:14
问题 i have a table that contains: itemid inventdimid datephysical transrefid 10001 123 2015-01-02 300002 10002 123 2015-01-03 3566 10001 123 2015-02-05 55555 10002 124 2015-02-01 4545 The result i want itemid inventdimid datephysical transrefid 10001 123 2015-02-05 555 10002 123 2015-01-03 3566 10002 124 2015-02-01 4545 MY query: SELECT a.itemid,a.inventdimid,max(a.datephysical),a.transrefid FROM a where dataareaid = 'ermi' group by a.itemid,a.inventdimid it is invalid in the select list because

get max ids by group mysql

此生再无相见时 提交于 2019-12-25 04:14:34
问题 I have this table called sw_sowing ----------------------------------------------------------------- id | id_unit | date | id_variety | type | status | ----------------------------------------------------------------- 1 | 1 | 2017-08-10 | 1 | SW | 200 | ----------------------------------------------------------------- 2 | 1 | 2017-10-10 | 1 | ER | 100 | ----------------------------------------------------------------- 3 | 1 | 2017-11-30 | 2 | SW | 100 | ---------------------------------------

Grouped Rolling Average by Date

对着背影说爱祢 提交于 2019-12-25 03:56:17
问题 I have data at a Day Level. Each day always has more than 1 value, and the days are not necessarily in consecutive order. I want to create a calculation for the mean on a particular day and the rolling 14 day mean. I have tried doing this in R but I am not having much luck. I think I am close though. Basically rolling mean and regular mean grouped by date. Thanks so much, I'm going crazy since I think I'm so close! library(plyr) library(zoo) help=ddply(data, .(DATE), roll_avg14 =rollmean

SQL Select latest row by date

你。 提交于 2019-12-25 03:53:56
问题 I have a large amount of data that updates every 10 minutes or so. There are 128 unique ID's that need to be returned but with only there latest values CURRENT CODE SELECT DISTINCT id, MAX(extractdate) AS [extractdate], total, used, free FROM maintable INNER JOIN datatable ON maintable.unkey = datatable.dataunkey GROUP BY id, total, used, free ORDER BY id CURRENT OUTPUT id extractdate total used free 1 2014-08-28 00:20:00.000 50 20 30 1 2014-08-28 00:30:00.000 50 30 20 1 2014-08-28 00:40:00

SQL group function nested too deeply

房东的猫 提交于 2019-12-25 03:50:13
问题 I'm trying to create an sql query that will return the smallest occurrence of an id appearing between two tables however I keep getting the error with the line HAVING MIN(COUNT(E.C_SE_ID)) . Oracle is saying that the group by function is nested too deeply. I cannot think of another way of returning C_SE_ID SELECT CS.C_SE_ID, MIN(COUNT(E.C_SE_ID)) FROM COURSE_SECTION CS, ENROLLMENT E, LOCATION L WHERE CS.C_SE_ID=E.C_SE_ID AND CS.LOC_ID=L.LOC_ID AND L.BLDG_CODE='DBW' GROUP BY CS.C_SE_ID HAVING

Use group by in and return identity of the row

帅比萌擦擦* 提交于 2019-12-25 03:50:08
问题 For this table... id type food price -------------------------- 1 veg carrot 10 2 veg turnip 11 3 fruit bramble 6 4 fruit rasp 4 5 fruit current 9 ... I can return the max price of the most expensive food for each food type like this... select max(price) from tableName group by type; But I'd like to return the id number of each row that contains the most expensive food for each food type. And return one and only one row per food type. Ie return this.... id ---- 2 5 ... This is a simplified

Group By Date Range of Sequenced Only

混江龙づ霸主 提交于 2019-12-25 03:45:13
问题 I am trying to generate a date range sequence and put date in second row if sequencing is break. fldDate TotalNo 2015-04-01 10 2015-04-02 10 2015-04-03 10 2015-04-04 10 2015-04-05 10 2015-04-06 10 2015-04-07 10 2015-04-08 10 2015-04-09 12 2015-04-10 12 2015-04-11 12 2015-04-12 12 2015-04-20 12 2015-04-21 12 2015-04-22 12 2015-04-23 12 2015-04-24 12 2015-04-25 12 I am really stumped I want this table as StartDate EndDate TotalNo 2015-04-01 2015-04-08 10 2015-04-09 2015-04-12 12 2015-04-20 2015

MySQL select using datetime, group by date only

随声附和 提交于 2019-12-25 03:14:34
问题 Is is possible to select a datetime field from a MySQL table and group by the date only? I'm trying to output a list of events that happen at multiple times, grouped by the date it happened on. My table/data looks like this: ( the timestamp is a datetime field ) 1. 2010-03-21 18:00:00 Event1 2. 2010-03-21 18:30:00 Event2 3. 2010-03-30 13:00:00 Event3 4. 2010-03-30 14:00:00 Event4 I want to output something like this: March 21st 1800 - Event 1 1830 - Event 2 March 30th 1300 - Event 3 1400 -