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 2008 Forums
 Transact-SQL (2008)
 SQL QUERY

Author  Topic 

tyekhan
Starting Member

29 Posts

Posted - 2013-05-30 : 07:45:49
I creating a new table on SQL Query, as you can see below,


SELECT OverallInfo.CusID AS ID, OverallInfo.CallDate, OverallInfo.CallTime, OverallInfo.CustomerID AS Outcome, OverallInfo.AgentName,
OverallInfo.ContactName, OverallInfo.ClientRef2 AS [Mobile Number], OverallInfo.Postcode,
'Discounted Amount' AS ['Discounted Amount'], OverallInfo.UpData AS [Date To Collect Payment],
OverallInfo.upTime AS [Time To Collect Payment], OverallInfo.NotesDelivery
FROM OverallInfo INNER JOIN
RC ON OverallInfo.LastRC = RC.RC
WHERE (RC.Success = 1)



i want to create some extra columns that are not in any of the current tables its called 'Discounted Amount'

On access you would just do is, Discounted Amount:""
But how would you do the same on SQL Query

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-05-30 : 08:17:38
Depending on what you want to get in the new column, it can be one of these or something similar
-- if you want the new column to have the value 'Discounted Amount' in every row
'Discounted Amount' AS [Discounted Amount] ,

-- if you want the new column to have an empty string in every row
'' AS [Discounted Amount] ,

-- if you want the new column to have zero in every row
0 AS [Discounted Amount] ,

-- if you want the new column to have an empty string in every row
NULL AS [Discounted Amount] ,
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-05-30 : 08:31:12
I think its the second one that OP is after

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

tyekhan
Starting Member

29 Posts

Posted - 2013-05-30 : 09:32:19
Thanks the second one worked fine

quote:
Originally posted by James K

Depending on what you want to get in the new column, it can be one of these or something similar
-- if you want the new column to have the value 'Discounted Amount' in every row
'Discounted Amount' AS [Discounted Amount] ,

-- if you want the new column to have an empty string in every row
'' AS [Discounted Amount] ,

-- if you want the new column to have zero in every row
0 AS [Discounted Amount] ,

-- if you want the new column to have an empty string in every row
NULL AS [Discounted Amount] ,


Go to Top of Page
   

- Advertisement -