Skip to content

Tag: sql

SQL sort by each hour with different dates

I have a sql table like this How to I sort by each hour to get this: Your help is very much appreciated 😀 Answer Here is a MySQL solution: select DATE_FORMAT(min(time), ‘%h:00’),sum(occ_val) from tbl group by hour(time) See https://www.db-fiddle.com/f/czudbp5zug6HxX4TFV26GT/0

Timeserial not recognized built in function in MS SQL

I am trying to implement an SQL query that gets records between today’s fixed timing 18:00 and yesterday’s fixed timing 18:00 based on a Date time column that I have in my table. I tried this query But, it’s throwing an error Timeserial is not a recognized built-in function name. Any ideas p…

Select max entries in a range in SQL server

I have a salary column where I have to select between range of 10000 and 20000 and also the top rows of max salary. Column I have: Rows I want to select I can use top n rows but that will apply on to this column. What I want to do is, say if this column has 2 rows that

Filter table to leave out specific rows

I have the table and now I want to list every ProjectName where there is no specified Leader like this: Right now I only know how to filter all ProjectNames with Leaders, but not the way to filter them the other way! Any help is appreciated 🙂 Answer One way to do it is with aggregation and the condition in