Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Fill in "missing" value in a table

Avatar of carrp
carrp asked on
Microsoft SQL Server
2 Comments1 Solution225 ViewsLast Modified:
I have a table that currently looks like this

Field 1 Field2 Field3
X1         A       9
X1         B       5
X2         A       3
X2         B       2
X3         A       6
X4         A       5
X4         B       1

Field 1 is a code for a sales agent.
Field 2 is a business type.
Field 3 is the number of sales.

Notice that agent X3 does not have a B associated with it. The only values that will ever be present in Field2 are A or B (they are mutually exclusive). I would like every value in Field 1 to be associated with both codes A and B. I'd like to table to look like this:

Field 1 Field2 Field3
X1         A       9
X1         B       5
X2         A       3
X2         B       2
X3         A       6
X3         B       0   <- I want to see a zero here
X4         A       5
X4         B       1

How can I achieve this?