The sql database table named ‘data’ has the fields ‘date’, ‘project_id’ and ‘amount’. I am able to retrieve the total amount spent on a single project with the code below: $sql = “SELECT sum(data….
SQL: how to pivot dimensions in a column?
I’m looking to do the following: Raw table: this has just two articles, their traffic channels, and unique pageviews SELECT * FROM website_content_table Returns: I want to return a table that …
Cannot resolve the collation conflict between this and that
I have data from 2 different databases, which i need to consolidate and compare which each other. An example: select distinct CustomerNo from DB1.dbo.TableCustomers UNION ALL select distinct CustNo …
bad date format for pivot
together I can not figure out why in PowerPivot or Excel a Microsoft query does not provide the date fields in the format for Excel as they are necessary. I have already gotten from you in another …
Get value of column related to value of column in other rows
I’ve a current table like this and would like to obtain this desired table: As you can see, this desired table should have a fourth column which indicates me the proportional value of the price in …
SQL Select between mixture of text and numeric
Not sure if it’s possible to do this in SQL but… I’m having difficulty selecting results between certain criteria. I have a column that is a mixture of text and numeric. For example: LOC:05-04-01. I’…
function that allows grouping of rows
I’m using SQL Server Management Studio 2012. I have a similar looking output from a query shown below. I want to eliminate someone from the query who has 2 contracts. Select Row_Number() over (…
Update values in column
I have following SQL-Table: A B C D “1” 2 3 “4” “2” 4 4 “5” “4” 1 6 “9” I would like to remove the “” So my result should look like this: A B C D 1 2 3 4 2 4 4 5 4 1 6 9
Dynamic horizontal aggregate (AVG)
I have a table which contains 3 float(nullable) columns: Value1 || Value2 || Value3 NULL NULL 100.00 10.00 20.00 NULL 10.00 10.00 100.00 I need to get the …
Grouping by column and rows
I have a table like this: +—-+————–+——–+———-+ | id | name | weight | some_key | +—-+————–+——–+———-+ | 1 | strawberries | 12 | 1 | | 2 |…