Skip to content

Tag: sql-server

T SQL Count and Group by calculable column

This code gives the following table cntqueue cntdate cntINKTONERBLACK signalcolumn Queue01 2001-04-04 3 0 Queue01 2001-04-05 1 0 Queue01 2001-04-06 100 1 Is there a way to count ‘1’ in signal column and group 1st column to have? cntqueue NumberOfJumps Queue01 1 Answer You can use a subquery:

Select all rows between dates

I have a #tmp table that looks like the following. It has a total of three lines. title receipt_date decision_date “It wasn’t as bad as I thought it would be” 2017-06-12 15:07:10.893 2017-06-23 09:37:31.667 “It wasn’t as bad as I thought it would be” 2017-07-11 10:35:24.337…

SQL query join tables data

I have 2 tables Users and TimeSheets, Timesheets table has column UserId which is users id form users table obviously 🙂 Logic And I’m trying to get all data of Timesheets table plus just name of user from users table but somehow it seems like my query is other way around! Now I know this might be a simp…

Find min and max data column in Table

I have a table that specifies exactly what date and time each employee was in a particular office. EmployeeTable looks like this: id EmployeeID DateP TimeP 1 11111 1397/01/02 01:30 2 11111 1398/05/09 05:30 3 11111 1398/06/07 05:10 4 22222 1398/08/09 06:12 5 22222 1399/02/01 07:15 6 11111 1399/07/02 08:51 7 11…

SQL Substring Case Condition

I’m trying to solve the following question on SQLPAD. Write a query to return the number of actors whose first name starts with ‘A’, ‘B’, ‘C’, or others. The order of your results doesn’t matter. You need to return 2 columns: The first column is the group of act…