• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 403
  • Last Modified:

sql server query

I have a table that has city, state, and zip columns.

When I write  a query as follows:

select city, state, zip from address_table

Open in new window

it will give me what I have in the table, but I want to create a virtual column with default value in my sql statement.  For example

select city, state, zip, county from address_table

Open in new window

I don't have a county column in my table and I don't want to add that to my table.  I want to create a county column in my sql statement with a default value 'Los Angeles'.  How do I write a sql statement that will show all the value in the address_table and plus a virtual column with default values of 'Los Angeles'?

1 Solution
Paul JacksonSoftware EngineerCommented:
select city, state, zip, 'Los Angeles' as county from address_table
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
The above answer is correct assuming that by 'default' you mean value for all rows.

Explain further for us what you're trying to pull off here.  
Are you trying to do a look for each city-zip to county?
countyprobSystem AnalystAuthor Commented:
I am trying to use the BI map in the reports and the query needs have county so that I create a map based on county.  My table doesn't have that field.

thanks Jack
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now