Search
 
SCRIPT & CODE EXAMPLE
 

SQL

sql server pivot rows to columns

select Firstname, Amount, PostalCode, LastName, AccountNumber
from
(
  select value, columnname
  from yourtable
) d
pivot
(
  max(value)
  for columnname in (Firstname, Amount, PostalCode, LastName, AccountNumber)
) piv;
Comment

sql pivot rows to columns

SELECT *        -- Total invoices per gender
FROM (
    SELECT invoice, gender
    FROM sales
) d
PIVOT (
    sum(invoice)
    FOR gender IN ('F' AS "Women", 'M' AS "Men")
);
-- Table Sales:
CREATE TABLE sales (
    gender VARCHAR2(1 BYTE),		-- 'F' or 'M'
    invoice NUMBER
);
Comment

PREVIOUS NEXT
Code Example
Sql :: find all tables with column name 
Sql :: limit offset sql server 
Sql :: mysql create table query 
Sql :: odd record sql query 
Sql :: sql left 
Sql :: sql server current time without date 
Sql :: to_char oracle 
Sql :: mysql auto increment column 
Sql :: delete top 10 rows in sql 
Sql :: @firebase/database: FIREBASE WARNING: update at /users failed: permission_denied 
Sql :: sql 2nd highest salary 
Sql :: download sql server for mac 
Sql :: create table from existing table in sql 
Sql :: sql server change column data type 
Sql :: install mysql for fedora 34 
Sql :: postgres left join 
Sql :: sql select non unique 
Sql :: consecutive numbers sql 
Sql :: find log file postgresql linux 
Sql :: pgadmin see indexes 
Sql :: difference between 2 query results sql server 
Sql :: sqlite commands 
Sql :: convert rows into columns in oracle 
Sql :: right join sql 
Sql :: how to search query in python3 sqlite3 
Sql :: sql pivot 
Sql :: relation does not exist postgresql 
Sql :: mysql if statement in where clause 
Sql :: to show sp in sql server 
Sql :: insert to postgres table 
ADD CONTENT
Topic
Content
Source link
Name
4+5 =