I have a query I can not seem to get to work. I have a table like this: ThingID, FK_ThingTypeID, Etc… And I want to select records in the order they were inserted, but group them by type. So if the data looks in the table is in the following order: I want to get select the records like this:
Tag: group-by
How to group distinct values and calculate fields in one SQL query
This is only my second time using Stack Overflow so I’m open to any constructive criticism on how to better format my questions. I have a list of orders and I’m wanting to create a table of useful customer information. I’ve created a new table that identifies unique customers (using just a select distinct of customer IDs) but I’m not
SQL query on two tables using two column as keys
I started studying SQL (not MySQL as it seems to be different in some parts) and I encountered this problem that i could not figure out how to solve I have the following tables: CREATE TABLE …
SQL Date range by month returns in multiple rows
I am looking to get the count of entries by the month. However, this is returning the total count. I would like it to be something like. Month —– Count January —- 500 February —- 600 If I can’t get the month in there, thats fine, but I would definitely like to have it so the count has its own
Compare two values in a row
select event_slots.id as event_slot_id, u.first_name, u.id AS user_id, sum(case when next_round = 1 then 1 else 0 end) AS yes, sum(case when next_round = 2 then 1 else 0 end) AS no from event_slots …
mysql get result from join table
I have a tables person and exam. I want to show data where all exam is PASS, show the latest exam pass_date. like table below what query to get it? please help. thanks! Answer You can use aggregation and conditional expressions: Note that for this sample data, you don’t need to bring in the person table to get the results
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 …
Sql Syntax to tag rows in a table where this specific criteria appears at least once or more
I am using SQL Server 2014 and I have a table (t1) which contains a list of 6 numbers in more than 25,000 rows. Extract of t1 is given below: Id F1 F2 F3 F4 F5 F6 1 5 11 15 …
SQL Stored Procedures, Combining rows with derived variables
I’ve been away for sometime and need help with, what is probably a simple solution but at this time I’m stuck. I have this select statement and need to combine rows with like elements for the same department but the group by would have a very large select list, is there another way like MERGE? Here is the sql stmt
SQL query to display Count of records based in range from another table
I have two tables Range and Employee. Range table consists of columns (Available programs for that salary like platinum and silver etc). Employee table has columns https://i.stack.imgur.com/RKaXP.png I want to write a SQL query in such a way that it gets the count of employees who fall under the given salary range in range table, please refer screenshot for tables