Skip to content

Tag: sql-server

SQL replace a string starting with a specific character

I have a column with text/sentences that may include strings starting with ‘@’. I need to remove all strings starting with ‘@’ from the texts. For example: Is there any function that can do the trick? I have tried the following but this removes only the ‘@’ from the string:…

Count amount of same value

I have a simple task which I to be honest have no idea how to accomplish. I have these values from SQL query: I would like to display a bit modified table like this: So, the idea is simple – I need to append a new column and set ‘Multiple’ and ‘Single’ value depending on if custo…

SQL query pivot, move values to top

I’ve created a PIVOT query and the results are fine, however. I would like to flatten the rows so to speak and move all values to the top of the list and NULLS to the bottom. http://sqlfiddle.com/#!18/7d17d/6 Instead of this: I would like to create something like this: Answer Change your ROW_NUMBER() to…

SQL Grand total without subtotals

I’m making a large SQL report in Orderwise, very roughly simplified as follows; I want a grand total at the bottom, without a bunch of subtotals dotted in throughout the report – therefore I don’t think I can use ROLLUP. The Subquery in there is of course a sub query and in the real thing th…