Total of Various Columns as a Separate Column in Oracle - sql

Could you help me out with an issue I have in Oracle?
Let's say I have a table that tells me about how many items were sold in each month, and looks like so:
Item
January
February
March
April
Computer
3
5
2
9
TV
10
12
16
14
Camera
22
25
20
27
What I need in the output is a table that would count the total number of items sold over the period, and would look like this:
Item
January
February
March
April
Total
Computer
3
5
2
9
19
TV
10
12
16
14
52
Camera
22
25
20
27
94
I am honestly not sure how to do that. Should I use grouping()?
Thank you in advance.

You don't need to use grouping at all just try to plus all columns as a new column Total.
SELECT T.*,
(January + February + March + April) Total
FROM T

Related

Count by unique values in other fields in Oracle SQL

I have table like this:
Year Month Type
2013 4 31
2013 3 31
2014 5 40
2014 6 41
2015 5 31
2015 7 40
2013 4 31
2013 3 31
2014 5 40
2014 6 41
2015 5 31
2015 7 40
2013 4 31
2013 3 31
I would like to count number of appearance of each combination. So output should be something like this:
Year Month Type Count_of_appearance
2013 3 31 3
2013 4 31 3
etc..
I've been using something like:
SELECT Year,
Month,
Type,
(SELECT COUNT (*)
FROM myTable
WHERE (...im lost in defining a condition in order to make this work...)
AS Count_of_appearance
FROM employee;
I'm lost at defining functional WHERE clause.
Problem is I a have a lot of fields like this and a lot of unique values. Table is 8Gb big.
You are looking for GROUP BY:
SELECT Year, Month, Type, COUNT(*) AS Count_of_appearance
FROM employee
GROUP BY Year, Month, Type
ORDER BY Year, Month, Type;
To ensure that the results are in the right order, you should include an ORDER BY as well.

SSRS: Horizontal alignment on a group

On my dataset I select information from four different years sorted by date and how many subscriptions I had on said date, which looks something like this:
Date Year Subs Day
15/09/2014 2015 57 1
16/09/2014 2015 18 2
17/09/2014 2015 16 3
14/09/2015 2016 10 1
15/09/2015 2016 45 2
16/09/2015 2016 28 3
12/09/2016 2017 32 1
13/09/2016 2017 11 2
14/09/2016 2017 68 3
24/08/2017 2018 23 1
25/08/2017 2018 53 2
26/08/2017 2018 13 3
What I'm trying to do is create an 'Year' Column Group to align them horizontally, but when I do that, this is the result:
result
Expected result:
expected result
Is this achievable in SSRS? I've tried removing the group =(Details), which gives me the desired result, except it only returns one line of information.
Any insight aprreciated.
By default, the Details group causes you to get one row per row in the dataset. In your case, I would suggest grouping the Rows by the Day column and create a column group by Year.
First, create the two groups and add columns inside the column group.
Then, add a row outside and above the Day row group. Place the headings here and then delete the top row. It should look like this:
Now these 4 columns will repeat to the right for each year and you will get rows based on the number of days in your dataset.

Dojo financial calendar

I'm using dojox/calendar/Calendar in the "month" view, and I'd like to adjust the start/end days of the month to match up with my company's fiscal or marketing calendars.
In these Fiscal/Marketing Calendar Month-views, I'd like to see something like this (note the square brackets indicating the beginning and ending of the fiscal month):
S M T W T F S
19 20 [21 22 23 24 25
26 27 28 29 30 1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19] 20 21 22 23
Basically I want a normal Gregorian calendar, but with the month shifted to put a non-standard date as the beginning and end of the month-view. I see various "alternate calendars" such as dojox/date/hebrew, but I'm not certain as to whether implementing my own "date" object is the right way to proceed.

How to programmatically layout days in a calendar in a way that matches the month and day of the week?

How can I do this?
I'm sure this has been done before. I've checked a couple of projects on github, such as calendar master, but they are all more complicated than what I need.
Oct 2013
S M T W T F S
30 1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31 1 2 3
Is there a best approach to do this? To layout days in a way that will match the day of the week for that month?
This will be made in a tableview, but I'm not looking for code, just the logic behind it. Unless there's a really good solution out there already.
Thank you!
The logic could be something like this (pseudo code):
get the weekday of the first day of the month in question
determine the number of days of the previous month
fill the first line
with leading final days of previous month, if any
the remaining days for the first week of the month in question
fill all other lines
fill the rest of the last line
with the first days of the following month, if any space left

Create a Multi-Column Report Using DevEx Grid

I have a daily sales report query and it have 2 columns like
days sales
1 12
2 65
3 25
...
30 24
but when I want to print it there is a lots of free spaces on paper, so I want to seperate query with a percentage (like % 33)
and result will be like 3 x 2 columns for one paper. and it will be more comfortable for me.
days sales days sales days sales
1 12 11 21 21 5
2 65 12 53 22 18
3 25 13 0
...
10 45 20 12 30 55
Any way to do this with DevEx Grid?
this is the view which I get
and I dont want such kind of empty paper for couple of records..
You will not find an easy way to achieve the desired result using XtraGrid, because it is not intended for reporting. I suggest that you create reports using another product: XtraReports.