Skip to content
Advertisement

Tag: pivot

SQL Pivot on Conditional Count

I have a table of vulnerabilities using SQL server, when I perform the following query select * from table The output looks like so. | Name | HostName | Week | | ————- |——-…

Pivot row values matching a pattern into column names

I have data that look like this: I would like to pivot these data so that for each set of rows with the same OH_IDNR and with the same common/non-unique part of OCV_VNAME, these columns are returned: OH_IDNR The common part of OCV_VNAME (e.g., ‘response_part_0_script_0_’) – n. One column for each unique part of OCV_Name (e.g.,’ resourceName’), with OCV_VALUE as

How can I get values of the Rating column together with their definition for every specific month by using Pivot with Month in MSSQL

Example : Data: Query: I get this error: Incorrect syntax near ‘,’. In line with ” Definition, Rating ” Result should look like this: Is this possible? Any help, please! Thank you! *The code above was based on PIVOT with MONTH(). Answer You could just use conditional aggregation: This syntax is somehow more flexible than the specific PIVOT operator (and

Rotate Database Table

Imagine I have a database table that has the following format: ╔══════════════════════╗ ║ Name Quarter Sales ║ ╠══════════════════════╣ ║ Joe Q1 700 ║ ║ Joe Q2 650 ║ ║ Joe Q3 …

Custom SQL response (JOIN TABLE)

I have two tables, table1 and table2 I want to link the two tables with the id, by grouping the information in one and the same answer. table1: ╔════╦══════════════╦ ║ id ║ product_id ║ ╠════╬═══…

Advertisement