Skip to content
Advertisement

Tag: count

SQL want efficient query to SELECT columnA, columnB FROM table1 WHERE both columnA, columnB are in columnC FROM table2 WHERE columndD > value

I’m searching for a more efficient method to accomplish something that I’ve already solved with a few different SQL statements. The problem: I have two tables a transactions table, and an accounts table The transactions table has columns that look like: acct_sending acct_receiving amount tx_datetime 100 101 10 yyyy-mm-dd hh-mm-ss 101 100 5 yyyy-mm-dd hh-mm-ss 101 200 1 yyyy-mm-dd hh-mm-ss

SQL count() not showing values of 0

i just started my journey with SQL, and made some tables of Cyclists, and Cycling Teams. Cyclist’s table contains columns: ID, Name, Team (which is foreign key of TEAMS ID) Team’s table contains columns: ID, Name, Number of Cyclists I want to Count number of Cyclists in each team, by using count() function ( Or basically any function, i just

Count and Group by 2 different columns SQL

I have below table and want to find out a count and group by that will show the number of times republic of ireland played a particular opponent regardless if they are the home team or away team I want something that will show like the below Thanks for help! Answer This is how I would do it — normalize

How can eliminate the line that counts everything [COUNT function in SQL]

I was running a code where I needed to see the top 10 results in a table. Unfortunately, I am with one more row that I was expecting. My results was the following: [Result after the query][1] [1]: https://i.stack.imgur.com/KCu7W.png Is there any way I can eliminate row 1 from my query? Thank you in advance for any assistance! Answer try

Simplifying SQL query

I’m using the Bixi public dataset found at https://www.bixi.com/en/open-data and have been asked to find “the average number of trips a day for each year-month combination in the dataset”. Here’s an example of the table from which I’m querying: id start_date start_station_code end_date end_station_code duration_sec is_member 85843 2016-04-15 00:00:00 6315 2016-04-15 00:05:00 6315 349 1 85844 2016-04-15 17:16:00 6315 2016-04-15

Count users with a condition in MYSQL

I have a table ‘helpdesk’ (detail below) that lists tickets. I’m trying to get the top 10 users who report issues, however there is a complication in the fact that users can report an issue for another user (think secretary for their boss as an example). The table structure is… Using the example above the count should return User 1

Advertisement