Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Same column with two different conditions.

Author  Topic 

indraja
Starting Member

6 Posts

Posted - 2007-03-02 : 00:43:52
I have a table with column as NAME.
I want to show same field from database twice each with different conditions

eyechart
Master Smack Fu Yak Hacker

3575 Posts

Posted - 2007-03-02 : 00:53:18
give us a little more info. How about typing out whatyou want it to look like. If you give us your table definition (DDL) we can even write the enitre query for you.


-ec
Go to Top of Page

indraja
Starting Member

6 Posts

Posted - 2007-03-02 : 01:03:11
quote:
Originally posted by eyechart

give us a little more info. How about typing out whatyou want it to look like. If you give us your table definition (DDL) we can even write the enitre query for you.


-ec




select the names starting with A in one column and starting with D in another column.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-03-02 : 01:17:19
SELECT Name AS A, '_' + Name + '_' AS B
FROM Table1


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-03-02 : 01:20:30
[code]Select
case when LEFT(name,1) = 'A' then name else '' end as Name1,
case when LEFT(name,1) = 'D' then name else '' end as Name2
From Tbl
[/code]

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page
   

- Advertisement -