Read the penultimate value ssrs - sql-server-2008

i have a report with parameter is the year i can select a multiple value
year
Data 2010 2011 2012
hp 14 25 30
Dell 17 18 20
what i need when i create the report i want to have another column with the last value concatenation with the last previous one like this :
year
Data 2010 2011 2012 2012/2011
hp 14 25 30 3025
Dell 17 18 20 2018
i tried this :
=Last(Field!Qte.value)+Last(Field!Qte.value)-1
but i had the wrong result i got this result :
year
Data 2010 2011 2012 2012/2011
hp 14 25 30 3029
Dell 17 18 20 2019
the problem is in this function
Last(Field!Qte.value)-1
it doesn't return the last previous value

Related

Data across multiple years using Sequelize.js

I am trying to find the month-wise data for multiple years in Sequelize.js
For eg.Stardate:2016-01-01 and EndDate:2017-02-29.
table1
date pack_price
2016-01-01 30
2016-02-19 30
2016-03-14 20
2016-10-01 50
2017-01-28 100
2017-02-25 29
Expected Answer:
date pack_price
Jan 2016 30
Feb 2016 30
Mar 2016 20
Oct 2016 50
Jan 2017 100
Feb 2017 29
Actual Answer
Date Pack_price
Jan 2016 130
Feb 2016 59
Mar 2016 20
Oct 2016 50
Node js code using Sequelize.js
Utils.table1.findAll({
where:{
tran_date: {
[Op.gt]: startTime,
[Op.lt]: endTime
}
},
attributes: [[Sequelize.fn('sum', Sequelize.col('pack_price')),'total'],[Sequelize.fn('month', Sequelize.col('tran_date')),'Month']],
group:[[Sequelize.fn('month', Sequelize.col('tran_date'))]],
raw: true,
}).then(total=>{
Utils.sendResponse(1, total, "success", q)
})
However, this works well for one year.Should work for multiple years.Do you have any idea how I could make this happen?.Thanks in advance.

Group Davg Results by Date

I have the following dataset that looks like this. I'd like to select only those who have a "1" for the ESITwoToFive variable and then compute the average total_ED_LOS for each unique dates. For example, the average for Feb 7th would only have the values from ID's 1 and 3.
ID CheckinDate ESITwoToFive Total_ED_Los
1 Feb 7 1 23
2 Feb 7 0 23
3 Feb 7 1 28
4 Feb 8 1 43
5 Feb 8 1 83
6 Feb 8 0 29
7 Feb 9 1 93
8 Feb 9 1 77
9 Feb 9 0 33
I'm using the following syntax but my output contains the same averages for every date.
SELECT [Fast Track Quality Research ESI Levels].checkin_date,
DAvg("total_ed_los","Fast Track Quality Research ESI Levels","ESITwoToFive =
'1'") AS Expr1
FROM [Fast Track Quality Research ESI Levels]
GROUP BY [Fast Track Quality Research ESI Levels].checkin_date;
Output that i'm getting...
Checkindate Avg LOS
Feb 7 24
Feb 8 24
Feb 9 24
Desired output....
Checkindate Avg LOS
Feb 7 24
Feb 8 54
Feb 9 86
I would suggest using the Avg function rather than the DAvg domain aggregate function, e.g.:
select t.checkin_date, avg(t.total_ed_los) as [Avg LOS]
from [Fast Track Quality Research ESI Levels] t
where t.esitwotofive = 1
group by t.checkin_date
The DAvg function in your example is calculating the average over all records for which ESITwoToFive = '1' before the data is aggregated by date, therefore you receive the same result for every record output by the query.

Mysql query for sum data

I want to make a report with MYSQL from this data
Table name: table
date name Quantity
13 Nov Rudy 40
13 Nov Mery 30
13 Nov Rudy 20
13 Nov John 10
14 Nov Rudy 20
14 Nov Rudy 30
I want the result like this
13 Nov Rudy 60
13 Nov Mery 30
13 Nov John 10
14 Nov Rudy 50
What query should I do?
thanks
I'm not sure if mysql has support for 2 columns in group by clause, so grouping by date + user should work. but if it has, you can skip this trick and replace this clause with (group by date name) as #RaymondNijland proposed.
select date, name, sum(quantity) as total
from your_table
group by concat(date, "_", name);

MySQL Sum and GroupBy in same query

I need some help designing a MySQL query that will return the sum of the AMT for each TYPE, grouped by YEAR. I'm sure this will be easy for someone. Just not for me! Thanks.
AMT YEAR TYPE
10 2010 A
20 2010 B
30 2010 B
20 2011 A
15 2011 A
11 2011 B
15 2011 A
13 2012 A
15 2012 A
20 2012 B
10 2012 B
10 2012 B
13 2012 B
17 2013 A
22 2013 A
24 2013 B
15 2013 B
20 2013 A
15 2013 A
11 2013 B
15 2013 A
13 2010 B
15 2010 A
20 2010 B
10 2011 A
10 2011 A
13 2011 B
17 2011 A
22 2012 A
Something like this:
SELECT SUM(Amt), Year, Type
FROM YourTable
GROUP BY Year, Type
SQL Fiddle Demo
you mean
select SUM(AMT) from table group by year, type
?
this will result in
2011 A X1
2011 B Y1
2012 A X2
2012 B Y2
etc...

RDLC report, generate a Pivot chart

I have the following data table format generated from SQL. Users can select which car models to be populated in the graph. There will be different number of Car models appearing in different reports. So there will be variable number of line charts appearing in the graph.(One line for one car model series)
Jan Feb Mar Apr May Jun
Honda 12 17 24 18 30 13
Toyota 15 20 10 15 30 40
Yamaha 30 25 30 15 13 40
Suzuki 35 15 13 40 45 45
Nissan 15 35 40 40 50 50
Kia 13 21 23 15 25 30
Mazda 25 25 30 32 15 40
How can I create a graph like this with RDLC reports?
This can be easily done using series groups in rdlc charting. The chart data source should be structured like this.
Brand Month Value
Honda Jan 10
Honda Feb 15
Honda Mar 20
Toyota Jan 20
Toyota Feb 21
Toyota Mar 22
Yamaha Jan 10
Yamaha Feb 11
Yamaha Mar 12
Add "Value" column as chart Values.
Add "Month" column as chart Categories.
Add "Brand" column as chartSeries Groups.