Posts by Joana Gonçalves • 99 points
4 posts
-
-1
votes1
answer708
viewsQ: How to know how many sales for each month?
I need to set up a query that brings the total sales of each month from a table called sales.SalesOrderHeader, but I’m not getting it. In this table there is a field OrderDate which is the date of…
-
4
votes5
answers12287
viewsQ: How to perform SQL concatenation
I need to concatenate year and month. How could I do that? select cast(year(orderdate) as int) + ' ' + cast(month(OrderDate)as int) as Year_Month From sales.SalesOrderHeader…
-
0
votes3
answers69
viewsQ: I have this cursor and the Where 'between' gives error. I wanted to select the years 2005 to 2008
DECLARE @Year int DECLARE db_cursor CURSOR FOR Select distinct Year(OrderDate) as Year From Sales.SalesOrderHeader Order by Year(OrderDate) OPEN db_cursor FETCH NEXT FROM…
-
2
votes2
answers87
viewsQ: I have this query and I’m not able to group by month
DECLARE @Year INT = 2005, @Month INT = 7 SELECT --SequenceNo = ROW_NUMBER() OVER(ORDER BY OrderDate), Year = Year(convert(int,OrderDate,111)), case Month(convert(int,OrderDate,111)) when 1 then…