Skip to content

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 …

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 ║ ╠════╬═══…