group-by

Usage of FIND_IN_SET in query [closed]

人盡茶涼 提交于 2019-12-12 01:48:58
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 years ago . $query=$this->db ->select(a.date,group_concat(s.name) ->from("tbl_attendance a,tbl_students s") ->WHERE ("FIND_IN_SET(s.student_id, a.attendance)")->group_by("a.date") ->get(); I wanted to know whether I have used the FIND_IN_SET and group_by functions correctly. Thanks in advance 回答1: FIND_IN_SET() returns the

MySQL GROUP_CONCAT duplicate entries

自古美人都是妖i 提交于 2019-12-12 01:43:10
问题 I have a problem with my mysql query, since it returns duplicate values for grouped attributes. For example, for the attribute q_id I receive 1_-_-_-_-_1_-_-_-_-_1_-_-_-_-_1_-_-_-_-_1_-_-_-_-_1_-_-_-_-_1_-_-_-_-_1_-_-_-_-_2_-_-_-_-_2_-_-_-_-_2_-_-_-_-_2_-_-_-_-_2_-_-_-_-_2_-_-_-_-_2_-_-_-_-_2_-_-_-_-_1_-_-_-_-_1_-_-_-_-_1_-_-_-_-_1_-_-_-_-_1_-_-_-_-_1_-_-_-_-_1_-_-_-_-_1_-_-_-_-_2_-_-_-_-_2_-_-_-_-_2_-_-_-_-_2_-_-_-_-_2_-_-_-_-_2_-_-_-_-_2_-_-_-_-_2 instead of 1_-_-_-_-_2 as expected. Two

How to join group item of Linq Query Group By?

我与影子孤独终老i 提交于 2019-12-12 01:42:23
问题 I have three tables that are related. Letter(Id,Name) SendLetter(Id,LetterId) ReciveLetter(Id,SendLetterId,Type,User) I want to get records of ReciveLetter that Group By SenLetterId & Type . I use this query. var dashbord = from d in db.ReceiveLetter where (d.SendLetter.LetterId == LetterId) group d by new { d.SendLetter, d.SendType } into g select new Items{ ...... }; It is group Items by SendLetterId and Type. I want to select join of UserName for each grouped item. for example: SendLetter:

How to group by week of the year dates or day dates that start on Sundays in oracle 10?

白昼怎懂夜的黑 提交于 2019-12-12 01:39:43
问题 Given a table: day_date (form of yyyy-mm-dd) column2 column3 I want to group the data by weeks, and the start of each week goes from Sunday to Saturday, but I want to display the day_date. I have looked around all over, and I'm rusty on my SQL. Thanks! 回答1: Assuming that day_date is a datetime field and that you want to display the start of the week as the grouping field, try a query of the form: select TRUNC(day_date)-TO_NUMBER(TO_CHAR(day_date,'D'))+1 week_start_date, MAX(column2), MAX

Create a view with totals from multiple columns

不打扰是莪最后的温柔 提交于 2019-12-12 01:29:38
问题 I need to create a view that displays various totals. I have two tables. One with UserIDs and a status code of a job application. The other has the UserID and 4 columns that contain Boolean 0/1. Each of those columns indicate a job skill (like run, jump, throw, climb). The view just needs to show the totals for each job skill, once for applications in progress, and once for those that are completed. I'm having trouble figuring out the group by and selecting columns for each skill. The User

Complex SUM from multiple tables

北战南征 提交于 2019-12-12 01:27:36
问题 Here are my tables: CREATE TABLE component (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT UNIQUE); CREATE TABLE file (id INTEGER PRIMARY KEY AUTOINCREMENT, component_id INTEGER, name TEXT UNIQUE); CREATE TABLE function (id INTEGER PRIMARY KEY AUTOINCREMENT, file_id INTEGER, name TEXT, FOREIGN KEY(file_id) REFERENCES file(id), UNIQUE(file_id, name)); CREATE TABLE version (id INTEGER PRIMARY KEY AUTOINCREMENT, version TEXT UNIQUE); CREATE TABLE data (id INTEGER PRIMARY KEY AUTOINCREMENT, file

really simple SQL Not a GROUP BY expression - Oracle [duplicate]

痴心易碎 提交于 2019-12-12 01:23:02
问题 This question already has answers here : ORA-00979 not a group by expression (8 answers) Closed 2 years ago . I tried to read about not a group by expression errors from some other posts, but all of them mention group functions such as MAX, MIN, etc. I'm not using any of it and it's a really simple query returning this sort of error. SELECT * FROM ad_voarnet_atendimento_pista WHERE is_closed = 0 GROUP BY prefixo ORDER BY prefixo What am I doing wrong here? Edit: The expected result is the

Android union query

拈花ヽ惹草 提交于 2019-12-12 01:22:19
问题 I have the following problem: I have a table called planing it has the following fields: idplaning, month, year, shop, target, sales so the table will contain info like this (ignoring the idplaning): month year shop target sales ------------------------------------------- 1 2014 ShopName1 3534 122 2 2014 ShopName1 2323 111 ... 12 2014 ShopName1 7865 328 1 2014 ShopName2 4544 544 2 2014 ShopName2 5675 642 ... 12 2014 ShopName2 4623 323 ... 1 2015 ShopName1 3534 122 2 2015 ShopName1 2323 111 ..

groupby in view of sql returns aggregate error

故事扮演 提交于 2019-12-12 01:17:39
问题 I am trying to create a view with this query as you can see here: SELECT dbo.Lines.LineNumber, dbo.Lines.DocumentNumber, dbo.Joints.JointNumber, dbo.Joints.JointSize, dbo.Joints.ShopField, dbo.Joints.WPS, dbo.WeldDetails.StateStep2 AS WeldState, dbo.Welds.WeldNumber, dbo.FitUps.FitUpNumber, MAX(dbo.WeldDetails.Id) AS WeldDetailId, MAX(dbo.FitUpDetails.Id) AS FitupDetailId, dbo.Joints.Id AS JointId, dbo.Ends.Name, dbo.Joints.THK, dbo.FitUpDetails.StateStep2 AS FitupState, dbo.Joints.Revision,

Using multiple group by having in single query

穿精又带淫゛_ 提交于 2019-12-12 01:12:09
问题 I have 2 queries to get the count of families having count = 1 and count = 2. SELECT Name, count(*) as c FROM Tablename GROUP BY HOUSE_NO HAVING c<=1; SELECT Name, count(*) as c FROM Tablename GROUP BY HOUSE_NO HAVING c>=2 and c<=4; But i need to combine those queries into single query.Like count1 count2 nooffamiliesHavingcount = 1 nooffamiliesHavingcount = 2 Please help me....Thanks in advance.. 回答1: You need to put your first count into a subquery: SELECT COUNT(CASE WHEN C = 1 THEN 1 END)