dbTalk Databases Forums  

Creating a "View" in SQL

microsoft.public.sqlserver.olap microsoft.public.sqlserver.olap


Discuss Creating a "View" in SQL in the microsoft.public.sqlserver.olap forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Granville
 
Posts: n/a

Default Creating a "View" in SQL - 11-15-2004 , 01:55 AM






Good day

I have a table in SQL with the following columsn in it

Column A Clumn B
6000 4
6001 5
6002 4
6003 8
6004 6
7000 8
7001 7
7009 8
7010 4
8000 3
8019 2
8020 5

I want to create a view where I can add a Column C but I want the Column to
show the following

Column A Clumn B Column C
6000 4 6000
6001 5 6000
6002 4 6000
6003 8 6000
6004 6 6000
7000 8 7000
7001 7 7000
7009 8 7000
7010 4 7000
8000 3 8000
8019 2 8000
8020 5 8000


AS you can see, I'm trying to create one parent for the 6000, 7000 and 800
Ranges.

Any suggestions

Granville




Reply With Quote
  #2  
Old   
Steve McHugh
 
Posts: n/a

Default Re: Creating a "View" in SQL - 11-15-2004 , 06:43 AM






Use the T/SQL ROUND() function. Books on line has the details.

Steve


Reply With Quote
  #3  
Old   
Michael Vardinghus
 
Posts: n/a

Default Re: Creating a "View" in SQL - 11-15-2004 , 12:26 PM



or you could say

select a, b, and left(a,1)+'000'

if a is a varchar field (not integer) - if integer you need to put in a
casting command above....like this:

select a, b, and left(cast(a as varchar),1)+'000'

the column b doesn't mean anything relating to you're grouping .. right ?

"Granville" <Granville (AT) discussions (DOT) microsoft.com> wrote

Quote:
Good day

I have a table in SQL with the following columsn in it

Column A Clumn B
6000 4
6001 5
6002 4
6003 8
6004 6
7000 8
7001 7
7009 8
7010 4
8000 3
8019 2
8020 5

I want to create a view where I can add a Column C but I want the Column
to
show the following

Column A Clumn B Column C
6000 4 6000
6001 5 6000
6002 4 6000
6003 8 6000
6004 6 6000
7000 8 7000
7001 7 7000
7009 8 7000
7010 4 7000
8000 3 8000
8019 2 8000
8020 5 8000


AS you can see, I'm trying to create one parent for the 6000, 7000 and 800
Ranges.

Any suggestions

Granville






Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.