Below is my SQL query Select [Item No_][Expiration Date],[Manufacturing Date] ,([Lot No_] ), Sum(Quantity)Quantity from [Warehouse Entry] Group by [Lot No_],[Expiration Date],[Manufacturing Date],[…
Tag: sql-server
How to set succeeding row values as empty if same with previous row
How can I convert this table: +———————+——————————-+——-+——-+ | PropertyName | Emergency | Count | Total | +———————+—…
How to use SQL function CONCAT with LIKE
I confirmed that the columns in the SQL table contain the results I’m searching for (the results being NA), but when I use the query below, no results are returned. Could I get some help with this …
Stored procedure to select values in table1, Group By, Sum, then insert those values into table2
I need a stored procedure to select rows from one table, do a Group By, Sum, and then insert the results into another table with their values. I guess I’ll have to do a merge when …
Cloning tree structure with guid
I am trying to clone tree structure to another table, but the problem is original table has guid as ParentId and Id and new table or table that I want to clone has int as ParentId and Id. I am trying …
Select all completed months until certain date in SQL Server
I have a query that returns certain time series information. But since I am doing analysis for each completed month, I would like to ignore the last month information so it does not contaminate the …
Smart way to write where col1 = x OR col2 = x on ALL the columns in SQL
Suppose I have 100 columns and I want to search for something but I don’t know which column to search. How can I write a loop that: SELECT * FROM table WHERE col1 = ‘x’ OR col2 =’x’ OR col3 = ‘x’ …
SQL for storing numbers from cold to hot for specific range?
We have a table that looks list this: date, val1, val2, val3, val4, val5 for a given row, val1 -val5 are unique and between 1 and 37 Using T-SQL, How can I list numbers 1 -37 by cold to hot with their frequency for a given date range? [![enter image description here][1]][1] Sample Output (NOT ACTUAL): Numbers by frequency descending:
What’s the point of BEGIN TRANSACTION; … ROLLBACK;
I understand that a transaction will automatically roll back whenever an error occurs. I read up on this for T-SQL from Microsoft and I found this syntax: BEGIN TRANSACTION; STATEMENT1; …
Format Phone Numbers With Characters
I need to format the existing phone numbers saved in my database. First, I need to clean the phone numbers with character. 801-113-1521 801.456.7891 1213-345-6789 ext 219 (323)567=2251 should be: …