Q

A "crosstab" query

I would like to generate a report from an SQL database where, for example, I have a table like this:

Field1  Field2  Field3
A       a1      2
A       a2      3
B       a1      1
C       a1      4
C       a2      3
D       a2      2

The report will look like this:

Field1  A1   A2     
A       2    3
B       1    0
C       4    3
D       0    2

How will I put this in a query?

This was first published in October 2003

Dig deeper on Oracle and SQL

Pro+

Features

Enjoy the benefits of Pro+ membership, learn more and join.

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchDataManagement

SearchBusinessAnalytics

SearchSAP

SearchSQLServer

TheServerSide

SearchDataCenter

SearchContentManagement

SearchFinancialApplications

Close