Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
1 vote
1 answer
48 views

Retrieve from 4 SQL tables with two count/group by values?

I have 4 tables tblProducts, tblSellers, tblViewedtimes, tblContactedtimes with below columns. How can we retrieve summary as below: tblContactedtimes SellerId CustomerID ProductID ContactedTime 2 ...
user1066231's user avatar
0 votes
3 answers
111 views

Aggregate may not appear in WHERE clause

I have this query SELECT a.Campaign, COUNT(DISTINCT a.Customer) AS 'Records', MIN(a.LastRecord) AS 'First Record', MAX(a.LastRecord) AS 'Last Record', MAX(a.daytime) AS 'Records up ...
Kaptah's user avatar
  • 9,899
0 votes
3 answers
53 views

Trying to merge groupby results to get a report in single query

I am using sqlite database and have a messages table which is storing who is sending what message to who and at what time. Messages table has following columns Id number/integer body string from uuid ...
Najam Awan's user avatar
  • 1,145
0 votes
1 answer
35 views

Joining 2 tables but only show values from 2nd table once in 1st table

I've been racking my brain trying to solve this problem. I'm using Presto SQL. I have 2 tables: trx (transactions per day): | date | usage | deposit_id | | -----------| -------- |------------|...
Sam Widjaja's user avatar
0 votes
0 answers
27 views

MySQL - Join Table, Use COUNT and GROUP BY [duplicate]

I have question about MySQL "join table". Here I want to combine 3 tables. However, I need to count one column and group by it. I've no idea about the order of the codes. I failed to make it ...
Flora Jiang's user avatar
0 votes
2 answers
47 views

Sumifs in SQL with dates filters

I am trying to write a query to produce a new table which will sum ifs the 'gross amount' from existing table (say A) when the following conditions meet: if reporting date is less than or equal to A. ...
Tanuj's user avatar
  • 1
1 vote
2 answers
122 views

Effectively executing Conditional NOT IN Subquery with JOIN and GROUP BY

I need to adjust the following select statement to effectively filter out 523 records where 'first_date_purchased' is less than 'first_date_watched'. The following select statement returns 20778 ...
Karel Prinsloo's user avatar
1 vote
2 answers
82 views

List out the all messages of user whether it is in sender or reciver by item id

I want the solution like each item id all messages between sender and receiver and need all rows belongs to user i.e. if sender id = 3 and receiver id = 25 then it will list out all message of between ...
bhawani's user avatar
  • 69
-1 votes
1 answer
66 views

Filter out the latest message of user whether it is in sender or reciver by item id

i tired group by with item id by using max with id but not able to filter out the single row only for each item id in table with latest message whether user login as sender or receiver. below is my ...
bhawani's user avatar
  • 69
0 votes
2 answers
63 views

Laravel eloquent GROUP BY

I have four tables: supplies, stocks, stock_ins, and stock_outs. In the Stock controller, I want to sum the total stock_out for each supply . For this, I have used the following query: $supplies = ...
Jahangir Shah's user avatar
0 votes
2 answers
100 views

Get row of data for MAX value over GROUP BY and JOINS

I am working with the ml100k dataset to write a query that can fetch me the most rated movie for every age. Here's how my tables are defined. users id | age | gender | occupation | zipcode ratings ...
vnk's user avatar
  • 1,082
1 vote
2 answers
127 views

MySQL Joining same table multiple times makes count go weird

Edited to clarify and simplify I have the following query select Signups.user_id, Count(timeoutTable.user_id) as timeoutCount, Count(confirmedTable.user_id) as confirmedCount from Signups left ...
Caleb's user avatar
  • 621
0 votes
1 answer
11 views

MySQL Getting filtered row from one table based on a value in another table

I am having an issue joining these two tables. The query below will return ID-A 1 and 8. However, I also want to check if ID-A has StatusCode= 2 in TableA. How do I join the two tables that return ...
Allen King's user avatar
  • 2,526
-2 votes
1 answer
48 views

Get percent of column value count compared to same column value count in another table during certain time period grouping by column value

Looking for share of each Agent's rows where task = 'Stalking' in table Stalking compared to occurrences in table Assigned during Min and Max stalkDate in table Stalking. Table Assigned Agent task ...
Kaptah's user avatar
  • 9,899
0 votes
1 answer
49 views

Laravel: GroupBy and orderBy not working together

I'm trying to select all attachments of a person and group by a field but if I add orderBy clause to show only last document of that category it doesn't work. It always use first id to group. Using -&...
Loris's user avatar
  • 1

15 30 50 per page
1
2 3 4 5
99