Skip to content
Advertisement

Tag: group-by

How to tell MariaDB/MySQL that a column is unique due to HAVING clause

With ONLY_FULL_GROUP_BY set (which I don’t want to/can’t change) the following query errors with ERROR 1055 (42000): ‘dbname.test1.person_id’ isn’t in GROUP BY (or equivalent longer message in mariadb). How can I “tell” MySQL that I know the person_id is unambiguous because of the HAVING clause? I don’t want to use ANY_VALUE because that isn’t available in all the dbs where

Group numbers by 45 in mysql

I have a database in which I store wind direction readings by degrees. I need to do two things really, i need to group all readings by 45 (basically 45 degrees between “N”, “NE”, “E”, “SE”, “S”,”SW”,”W” and “NW”) and then i need to find the percentage of each of those groups in all readings. This is where i’m stuck

SQL groups inside groups

I have transaction data like this example: Name | Price George | 20 George | 20 George | 20 George | 30 Paul | 20 Paul | 20 Paul | 30 Paul | 30 Paul | 35 I need to group by …

Group by issues with multiple columns

I am having trouble making a query work. I am selecting 5 columns, using 3 to filter and 1 to count: I keep getting an error that the other columns have to be grouped by or aggregated. I’m trying to get the total students per class per professor. I’m only selecting the other columns so I can filter out data.

Get comments per video and total sum of comments per video channel

In addition to Get total sum of video comments for each video I noticed that I can’t use v.commentCount because I cleaned some data and now the column is inaccurate. So I need to count the videoId comments and the total videoID comments with the comment table. I have a table video and a table comments. video.channelId maps to comments.videoID_channelID

Retrieve the first occurrence of a record by ID in SQL

I am trying to import some data into Excel from a SQL server, but I am having some issues. It’s my first time writing a query, although I am able to get the entire dataset, I have realized that the data is full of duplicates. I want to get rid of duplicates in Excel and only keep Unique records. I

Advertisement