How to get custom rows in Pentaho? - mysql

I have one table with some information.
Name Age Address
Tejas 20 xyz
Jeffie 21 por
jason 19 brazil
This table i get from query.I want to show row which has age less than 20 with green and greater than 20 is red.(Note:Whole row should get the color).Is there Addins for tables for such scenario? Can anyone help me?

Related

SQL QUERY to show records of names that are recorded several times and are unique towards each other

For example, let us consider this table:
In this image consists of rows of 8 where names like Mike,Glenn,Daryl,Shane and Patricia is included with their respective ages
Id
Name
Age
1
Mike
25
2
Glenn
19
3
Glenn
19
4
Daryl
56
5
Shane
30
6
Shane
30
7
Patricia
16
Now I want to insert the type of query that will show the names without repetitions like This, not like This
EDIT: I entered the data from first picture. The request is to list the names without duplicates, as shown in the second and third picture but I will not convert them to text.
DISTINCT specifies removal of duplicate rows from the result set.
SELECT DISTINCT Name
FROM tablename
see: use DISTINCT in SELECT
You can use GROUP BY to achieve it.
SELECT * FROM your_table
GROUP BY your_table.name
ORDER BY id
With the data you gave, the result from this query will be:
id
name
age
1
Mike
25
2
Glenn
19
4
Deryl
56
5
Shane
30
7
Patricia
16

How to get the count of MySQL count occurrences of id in laravel?

I am using laravel framework. i want to get the count of MySQL count occurrences of id. Here is my problem. My table name is download_histories. Here is my record for demo :-
Table:- download_histories
id alt_image_id
1 25
2 25
3 26
4 27
5 29
6 26
Now look at the table. Now this table having 6 records and alt_image_id 25 coming twice times and alt_image_id 26 coming twice times .and 27 and 29 coming once .
Now i want the result when group of alt_image count is greater then equal to 2. Now i want the count of groupby records can anyone help me. I want the count that is 2
i have done so far :-
DB::table('download_histories')
->select(DB::raw('count(download_histories.user_id) as totaluserdownload'))
->groupby('alt_image_id')
->having('totaluserdownload','>=',2)
->get();
Note : i want the count not get the data . Please help me. Thanks in advance :)

Sort values in two column and insert order position into another column in mysql

I have a database about sports event that contains:
*User ID
*Amount of Points that the user got on that event
*Time (HH:MM:SS) that took the user to complete track.
How can I first sort them by no. of points, then if two users have same amount of points, by time (shorter is better); and then insert the places to rows?
I have database like that:
ID No. of Points Time Place
------------------------------------
1 15 00:56:00
2 13 00:55:15
3 17 01:00:00
4 17 00:57:00
5 19 00:52:15
I need to have it with places:
ID No. of Points Time Place
------------------------------------
1 15 00:56:00 4
2 13 00:55:15 5
3 17 01:00:00 3
4 17 00:57:00 2
5 19 00:52:15 1
I hope, you understand that. Sorry for bad English.
Best regards,
You can do this with update statement as follows.
SET #placeValue:=0;
UPDATE [Table Name] SET Place=#placeValue:=#placeValue+1 ORDER BY
[Amount of Points] DESC,Time ASC

mysql - get the average of the output average

I have 3 table. final,milestone and milestonewp consider that the three tables is foreigned key like milestonewp<--FK--milestone<--FK--Final .Then I have a column for determining the average of the milestonewp for a certain foreign key. Then getting that average to be average again to be displayed to the final table.Here is my visual representation
milestonewp
condition | mile_id
20 1
20 1
30 1
21 2
21 2
31 2
40 3
30 3
50 3
How can I average the average that the chart above will produce?
I'm trying to work on this
select avg(milewp_condition)
from logs_pms_r_milestone_wp
where mile_id=1;
but i dont have any idea how it can produce for the other mile_id
EDIT
The above code will produce something like this
avg(milewp_condition)
0
0
0
so then, i also want to average that 3 rows.
If I understand well this should be what you look for:
SELECT AVG(milewp_condition)
FROM logs_pms_r_milestone_wp
GROUP BY mile_id;
If you want to average all, just do:
SELECT AVG(milewp_condition)
FROM logs_pms_r_milestone_wp;
Regards

MySQL query involving complicated summing function

I don't know how to put my requirement in words but let me explain it with a table and output that I desire
The table looks like this
Package LanguageUsed UnitsSold
lmn basic 43
xyz pascal 20
abc basic 50
cba c 20
Output I want is
LanguageUsed UnitsSold
basic 93 43+50
pascal 20 20+ nothing
c 20 20+ nothing
I need to display number of packages sold in each language
How can I do this in MySQL?
I need to display number of packages sold in each language
You can do:
SELECT languageUsed, SUM(UnitsSold)
FROM yourTABLE
GROUP BY languageUsed