Skip to content
Advertisement

Tag: group-by

SQL INNER JOIN of sum distinct values

I have 3 tables called musics, singers and playlistInfos. I want to get Top 10 listened England musics.What kind of sql query help me? SELECT * FROM musics m INNER JOIN playlistInfo p ON p.musicID = m.id INNER JOIN singer a ON a.id = m.singerID GROUP BY p.musicID ORDER BY p.listened I try this one but I did not get

Create SQL statement with mulitple AND

I have a problem with creating right SQL request. This is my table: I would like to display all items that: -Are in warehouse A in number less than 2 -Are in watehouse B in number grater than 0 At the same time. I would expect item1 will be displayed. My code so far is: I know that warehouse =

Aggregation level is off (Postgresql)

I have Order data for 2 customers and their order. And I am trying to calculate what the sum for the price is for every customter for that specific order only for product N Table: This is my query: For some reason I do not understand it gives me several rows per same customer. I am trying to get only

MySQL Merge two queries based on mutual column

I have two queries that retrieve records from 2 different tables that are almost alike and I need to merge them together. Both have created_date which is of type datetime and I’m casting this column to date because I want to group and order them by date only, I don’t need the time. First query: Second query: What I need

SQL how to select a single value from a table with LEFT JOIN, In Google Datastudio

I have two tables one table called mailing_events and one table called mailing_outletcontact. Examples of my tables are below. The mailing table is very simple with no duplicates: My Second table “mailing_outletcontact” has duplicates in the email field. I am trying to query the database in Datastudio with my goal being to get the “outletcontact_id” field with my first table

Advertisement