I have a table of shipment numbers (can be duplicate) and a concatenated field of their origin – destination (can be duplicate). I have a select column that selects all of the origin-destinations for …
Tag: sql-server
Using select distinct with sum
I am not sure if what I want can be done but basically, I have a homework where I am supposed to come up with sql statements to filter through a database of a made up TCM company in any way. I wanted …
SQL Return last record where column value changed and amount of change
In MS SQL 2012, I have a table like such: Key | Entity | Value | DateTime ———————————————————– 10 A 800 …
Calculation of rank according to supplier table & sales table
I’m working with SQL Server 2014; I attached a purchase table (from suppliers) and sales table. First, I need to use a sales table based on the rankings from the purchase table, product bought first …
ERROR: varchar data type to a datetime data type resulted in error out-of-range value
I get this error message when I run the below query. Do you have any idea how I can solve this error? varchar data type to a datetime data type resulted in error out-of-range value I have been …
SQL Format(‘MMMM’) does not work in SQL Server 2008
I had this query select format([time], ‘MMMM’) as ‘Month’, count([time]) as ‘Application Usage’, count([time]) as ‘Application Usage’ from UserLogs UL where [time] >= …
Trigger to delete rows from table
I’m trying to create a Trigger for when records in a log table exceed a certain number of rows I want to start purging them by x amount of old records and keeping the new records by a certain date. …
Translate Excel business logic to T-SQL
I need to ‘translate’ some business logic from Excel to T-SQL, I’m having a hard time with it. It’s about figures from gates that count how many customers go IN and OUT of the stores. All DATA you …
How to convert Row to Column using Pivot?
I am trying to convert rows to column This is my table records Records SrID ProID Year Qty Months ————————————- 4444 112112 2019 22 THREE 4444 112112 …
Grouping other fields by common email
I’d appreciate any assistance people could provide with this one. I’ve tried to follow a couple of other posts (GROUP BY to combine/concat a column), but when I do this, it combines everything. I …