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)
 sql join in SP help.

Author  Topic 

android.sm
Starting Member

36 Posts

Posted - 2010-06-18 : 04:52:17
i want to add another column called CD_Cost to the below SP but not sure how to. thanks all


ALTER PROCEDURE [dbo].[asp_s_CO_Names]
AS

SELECT

tbl_Course_CO.CO_Name,
tbl_Course_CO.CO_ID,
tbl_CourseDates_CD.CD_Date,tbl_Course_CO.CO_SortOrder,
CD_MaxNumber -
COALESCE( (SELECT SUM(BO_Number)
FROM tbl_Bookings_BO
WHERE (BO_CD = CD_ID)),0) AS Available, CD_ID

FROM
tbl_Course_CO
left JOIN tbl_CourseDates_CD ON tbl_Course_CO.CO_ID = tbl_CourseDates_CD.CD_CO
AND tbl_CourseDates_CD.CD_Date > GETDATE()
And tbl_CourseDates_CD.CD_IsCancelled = 0

WHERE (tbl_Course_CO.CO_IsVisible = 1)
ORDER BY tbl_Course_CO.CO_SortOrder asc, tbl_Course_CO.CO_Name, tbl_CourseDates_CD.CD_Date

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-06-18 : 05:21:58
Add this before FROM

,CD_Cost

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

android.sm
Starting Member

36 Posts

Posted - 2010-06-18 : 09:04:48
thank you, it works :)

the date format im getting back is like 23/06/2010.

how can i format this in the SP so it returns a dat like: 23rd June 2010 or 24th June?
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-06-18 : 09:08:45
quote:
Originally posted by android.sm

thank you, it works :)

the date format im getting back is like 23/06/2010.

how can i format this in the SP so it returns a dat like: 23rd June 2010 or 24th June?


If you use front end application, do the formation there
Otherwise read about CONVERT function in SQL Server help file

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

android.sm
Starting Member

36 Posts

Posted - 2010-06-18 : 09:22:54
yes, using front end app and will do it there. thanks for your help.
Go to Top of Page
   

- Advertisement -