Quantcast
Channel: SQL Server Integration Services forum
Viewing all articles
Browse latest Browse all 24688

Display the sum value

$
0
0

Hi. Below is my db design: (I have room type description and 365 days column as below for table called BudgetRoomType)

RoomTypeDesc     1/1    2/1     3/1     4/1     5/1

----------------------------------------------------------

DXK                     50      50       50      50      50

DXP                     50      50       50      50      50

- I am creating a stored procedure to retrieve the sum by a date input. For example my date input is 2018-01-02 (2nd January 2018)

- So i need to create a select statement to add DXK and DXP for 2/1.

- I have done something below, but its showing cannot convert date into string.

Declare @date datetime = '2018/01/02'

SELECT  Sum(*) As Value FROM BudgetRoomType
WHERE RoomTypeDesc in (Select RoomTypeDesc From RoomType)
AND @date = CONVERT(VARCHAR(2), Day(@date))  + '/'
           + CONVERT(VARCHAR(2), Month(@date))


Please help :-


Viewing all articles
Browse latest Browse all 24688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>