In 1 packing got 2 material and item sequence is 00010 and 00020. What I need is if I input material from item sequence 00010 in where statement which is ‘CB016’ , I can list out all the item sequence …
Tag: sql-server-2008
Query to find the city name with longest and shortest length
I’ve written a query to return me the cities with the shortest and longest length strings in a MS SQL SERVER database. Select city, len(city) as l From Station Where len(city) in ((select max(len(…
Calculate Profit Based on First-In, First-Out Pricing By Date Of Sale
How can I find the sales margin every Day via SQL, assuming they are sold in the order they were purchased? Answer Please try this solution – group by sale_date
How to have a NULL instead of No Value from a query
I had a query like: Then I tried But when it doesn’t find the named table returns not output, Value or Null value or anything I can work on. This is going to be used as a crosscheck. Does anybody have any idea? Answer Thanks for those who payed attention to what I exactly asked and for their responses. Here
SQL BACKUP and Restore Full backup
I have two full backups of different dates first full backup is of date lets suppose 21-05-2017 and I have restored that backup to client machine (RESTORE WITH NO RECOVERY) and now I got second full back on date : 26-05-2017 , now I want to restore that full backup on previous restored Full back on my client machine. Any
Using distinct with stuff/for xml path(”)
I’d like to put together only unique values in the concatenated string. My code is currently: This gives me the output I’d expect, but I would like to eliminate the duplicate values in the stuff/for xml path field. I’ve tried various combinations of distinct and group by in the stuff/xml section, but can’t piece it together properly. To clarify, for
Counting number of records with matching values in separate fields
database/SQL novice here. I have a table in DB MS SQL Server 2008 that looks like this: I want to find number of rows by values parameter1, parameter2, parameter3, number of request Result should be like this: How can I do it? Please help me. Answer
CONVERT issue in sqlserver with Msg 529 error
This statement is giving me a error VALUE column Datatype is TEXT in the RESULTS table. How can i overcome the above problem. please help ! Answer You can’t convert from text to datetime You must apply two convert operations. The first: From text to varchar The second: From varchar to datetime So your query will become: Plus: text datatype
How can I refactor the below code to make it faster?
This code is developed by my colleague, and it is really slow. I don’t want to create any temp table. How can I make this query faster? Answer
Can we write case statement without having else statement
I have this query: It is giving me o/p as Id A B NULL NULL NULL I don’t want to have NULL values in my output, I only want to compare in A and B, is it possible in case statement. Answer A case expression can only manipulate the value of an expression, not remove rows from the result. If