I have a database which contains 5 tables. And I want to find the names of courses that are enrolled by all “Automotive Engineering” students. I tried the below statements but it shows nothing. I execute the above query but it shows nothing. Can someone help me from here? Answer This is a kind of relational d…
Tag: join
How to join SQL column elements together?
I have an SQL table with the column named expenses like this I want to write a query to return all the elements of this column separated by a comma. For the above example output should be:- hotel,…
SQL Database Design Union Data Type? [closed]
This may be a basic question, but I’m curious about what the most reasonable “preferred” way to design a database with a union type is. What I mean is consider a table Post which has only 1 piece …
Trying to JOIN columns from two different tables
I have one table (city_data) with the columns ‘year’, ‘city_name’ and ‘avg_temp’. The other table is global_data and has the columns ‘avg_temp’ and ‘year’. I am trying to create a table which has the …
MAX COUNT BY GROUP BY Retrieve only max count records
I want to return only the max count record from the following grouping. This Returns: Ideally it should return only : Sort the manufname asc by Tried this but returns the same: Answer You can use dense_rank or rank window function. Also I have removed unnecessary aggregation in the top query. You can use TOP …
SQL Query to group by month and display individual month sum for a record
I’m trying to sum product codes with a particular description as total products sold in a month over the years. The two table used are: The date format is in ‘DD-MON-YYYY HH12:MI PM’. So far I’m able to formulate this: How do I separate the count as different month columns and get the …
SQL How to ask for a value multiply times in an Query [closed]
Good evening folks! Following Problem, I have three tables: Create TABLE Suppliers ( SID integer, sname varchar(50), adress varchar(50), PRIMARY KEY (SID) ) Create TABLE Parts ( PID integer, pname …
Finding unique number of IDs in multiple groups
I have a dataset that has doctors and the various practices they work in. Each doctor in my dataset works in at least 1 practice but as many as 17 different practices. I would like to know the unique …
inner join with subquery results differs for these data sets
CREATE TABLE IF NOT EXISTS `wcd` ( `id` int(6) unsigned NOT NULL, `wid` int(11) unsigned NOT NULL, PRIMARY KEY (`id`) ) DEFAULT CHARSET=utf8; INSERT INTO `wcd` (`id`, `wid`) VALUES (‘168’, ‘…
Include indicator of data present, but not include in results
I can’t quite explain it properly, hence the awful title. As an example, I would have a query that shows customer complaints, of a certain type, and the dates since those complaints. Something like …