[Solved] SQL Server 2008 : calculate date and price change

Something like: DECLARE @artSales TABLE (artid int, dt date, price money); INSERT @artSales VALUES (1, ‘20170102’, 10), (1, ‘20170108’, 10), (1, ‘20170112’, 8.50), (1, ‘20170115’, 8.50), (2, ‘20170102’, 20), (2, ‘20170109’, 20), (2, ‘20170112’, 35), (2, ‘20170116’, 40), (3, ‘20170101’, 500), (3, ‘20170111’, 500), (3, ‘20170130’, 500); SELECT artid, dt, oldPrice = price, PriceChange = … Read more

[Solved] I want to fetch data from table and append column name code to the value as key value pair. How to achieve this in SQL?

You can achieve it like following. SELECT ‘8=’ + CAST([8_length] AS VARCHAR(10)) AS [8_length] FROM [Your_Table] Note: If the column type is already VARCHAR, in that case you don’t need to use CAST solved I want to fetch data from table and append column name code to the value as key value pair. How to … Read more

[Solved] How to extract a string between two of the SAME delimiters T-SQL?

Use CHAR_INDEX twice: SELECT *, SUBSTRING(path, pos1 + 1, pos2 – pos1 – 1) FROM tests CROSS APPLY (SELECT NULLIF(CHARINDEX(‘\’, path), 0)) AS ca1(pos1) CROSS APPLY (SELECT NULLIF(CHARINDEX(‘\’, path, pos1 + 1), 0)) AS ca2(pos2) — NULLIF is used to convert 0 value (character not found) to NULL Test on db<>fiddle 1 solved How to … Read more

[Solved] SQL Server inner Join with the same table

List of critical model per store and main resources in stock if any or cero select a.sloc, a.model, a.stock critical, isnull(b.stock,0) ‘Main Resources’ from stock a left join stock b on a.model=b.model and b.sloc=”Main” where a.stock<5 For the last part of your request, I’m not sure what is needed for a new opened store. EDIT … Read more

[Solved] hide/remove header and footer

For each element in your header or footer, whether it be an image or a text box or anything else, right click on each item and select the ‘properties’ option at the bottom of the menu. Then select the ‘visibility’ tab and change from ‘show’ to ‘show or hide based on an expression’. Click the … Read more

[Solved] In SSRS 2008, how are parameters passed down to the DatSet Query… or can they?

In the query designer drag a dimension on top of your report. Chose an Operator and a Filter and check the checkbox by Parameters and BOOOM you have your parameter. If you go now into your report designer you find the parameter you just checked in the folder Parameters on the left navigation pane (on … Read more

[Solved] How to select specific data between Quotes (“)

this is Ugly, but will eventually work: COLUMN = ‘jksjdksls#$#$@@kskjfjf,”123,456,789″ lsnslkdswfnslsjfls’ left( right(COLUMN,len(COLUMN)-instr(COLUMN,””””)), instr( right(COLUMN,len(COLUMN)-instr(COLUMN,””””)), “”””) -1 ) –> 123,456,789 This is what is done: We take this string ‘jksjdksls#$#$@@kskjfjf,”123,456,789″ lsnslkdswfnslsjfls’ find the first occurence of ” with instr(COLUMN,””””) –> returns 24 take the right end of the string with. Therefore we need to take … Read more

[Solved] Need a SQL Server query to eliminate the Highlighted Rows ( Returning Routes in Flight)

I have created a table named S65828793 with your provided data. First I have numbered the rows in ascending sequence of departure time. Then from that I have identified the flights that have been another flight within two consecutive days from opposite direction and marked those as returning flight. Then at last I have excluded … Read more