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 :: remove root password mysql 
Sql :: sql alter column 
Sql :: SQL SELECT TOP Equivalent in MySQL 
Sql :: sql join on a subquery 
Sql :: drush SQLSTATE[HY000] [2002] No such file or directory 
Sql :: finish transaction sql 
Sql :: mysql get only the field names in a table 
Sql :: mysql find max value row 
Sql :: change schema of all tables postgres 
Sql :: sql insert data 
Sql :: case statement in select query in sql 
Sql :: mysql mediumtext 
Sql :: mysql create pool 
Sql :: mysql size of database 
Sql :: oracle drop type 
Sql :: microsoft sql server python connection 
Sql :: creating sql table 
Sql :: SQL IS NULL With COUNT() 
Sql :: mysql error 1114 (hy000) the table is full 
Sql :: sql highest salary by location 
Sql :: where clause for clob in oracle 
Sql :: mysql select database 
Sql :: what is drop in sql 
Sql :: mysql regex phone number 
Sql :: psql concat string and int 
Sql :: stuff in sql server 
Sql :: oracle datafile max size 32gb 
Sql :: postgresql populate data random 
Sql :: how to install sql server management studio in ubuntu 18.04 
Sql :: difference between left outer join and left join in sql 
ADD CONTENT
Topic
Content
Source link
Name
4+3 =