I have Oracle g11 XE in Ubuntu 14.04, i will to show a table Without cutting , for example :
C_ID A_ID C_PRODUIT
---------- ---------- --------------------
1 1 real madrid
2 1 manunited
3 2 barca
4 3 barca
5 2 real madrid
6 5 barca
7 5 real madrid
8 10 juvantus
10 8 barca
11 1 chelsea
9 6
12 4
I do not want to appear so :
i will to delete the " ------------------------------ "
C_ID A_ID C_PRODUIT
---------- ---------- --------------------
1 1 real madrid
2 1 manunited
3 2 barca
4 3 barca
5 2 real madrid
6 5 barca
7 5 real madrid
8 10 juvantus
10 8 barca
11 1 chelsea
9 6
C_ID A_ID C_PRODUIT
---------- ---------- --------------------
12 4
IN SQL Plus:
set pagesize 1000;
Your cut will be after 1000 rows.
You can add this line in your glogin file, which is located under $ORACLE_HOME/sqlplus/admin. That way this line will be executed on every new SQL Plus session.
Related
I have a table called employee_comp_field, where salary fields are available
comp_field id | year_id | compensation_field
1 101 salary
2 101 bonus
3 101 pf
4 101 allowance
5 102 salary
6 102 bonus
7 102 pf
8 102 allowance
Then I have another table where employee salary data get stored emp_compensation against each field. As you can see emp_id 10 has three set of records as he got three time salary hike in the same year(year_id=101), which can be identified by salary_order field.
id | year_id | emp_id | comp_field_id | amount | comp_order
1 101 10 1 10000 1
2 101 10 2 1000 1
3 101 10 3 1000 1
4 101 10 4 100 1
5 101 10 1 12000 2
6 101 10 2 100 2
7 101 10 3 10000 2
8 101 10 4 10000 2
9 101 10 1 15000 3
10 101 10 2 500 3
11 101 10 3 150 3
12 101 10 4 1500 3
13 101 11 1 13000 1
14 101 11 2 1300 1
15 101 11 3 null 1
16 101 11 4 150 1
I want to identify all the employees list with max salary_order
my desire output will be below:
id | year_id | emp_id | comp_field_id | amount | comp_order
9 101 10 1 15000 3
10 101 10 2 500 3
11 101 10 3 150 3
12 101 10 4 1500 3
13 101 11 1 13000 1
14 101 11 2 1300 1
15 101 11 3 null 1
16 101 11 4 150 1
as emp_id 10 got three time salary hike...so I retrieve the list of records with salary_order 3
and emp_id 11 got one ony so I retrieve that set of records ony with salary_order 1
Can someone please help me here, how to retrieve my desire output using hibernate criteria.
My thought is to first retrieve all the list based on emp_id and then using java stream if we can filter it out to get the desired output.
Please suggest the best possible way.
The best possible way.
is subjective. It can be the fastest, it can be the shortest. It could be anything.
I will give you an example of how you could build a query in mysql to replicate your output. This might be tricky to solve with Criteria though since the table is being self joined.
select a.*
from emp_compensation a
left outer join emp_compensation b on a.emp_id = b.emp_id
and a.comp_field_id = b.comp_field_id
and a.comp_order < b.comp_order
where b.emp_id is null
I want below kind of format in oracle reports 6i.
A B C A B C
1 1 1 6 6 6
2 2 2 7 7 7
3 3 3 8 8 8
4 4 4 9 9 9
5 5 5 10 10 10
enter image description here
SQL> select ID,rank() over(order by ID) RANK , dense_rank() over(order by ID) DENSE_RANK from a;
ID RANK DENSE_RANK
1 1 1
1 1 1
2 3 2
3 4 3
3 4 3
4 6 4
5 7 5
5 7 5
6 9 6
7 10 7
ORACLE select
calculate Sales، returns and the rest for a customer in the same table for the same product according to trans type
i need to calculate total sales and total returns and the rest for the customer and items.
and group by customer
Trans_Type:
1= Sales
2= Return
ID Trans_Type DATE Items_ID Quantity Clint_ID
--- ---------- -------- ---------- ---------- ----------
1 1 16-OCT-09 701555 3 1
2 2 12-DEC-09 701555 1 1
3 1 30-JUL-10 701511 63 2
4 2 30-JUL-10 701555 1 1
5 1 30-JUL-10 701234 2 3
6 1 30-JUL-10 701234 5 3
7 2 30-JUL-10 701511 1 2
8 1 30-JUL-10 701522 3 2
9 1 30-JUL-10 701555 2 3
10 1 30-JUL-10 701555 4 2
11 2 30-JUL-10 701555 2 2
If I understood everything correct you need to use case when ... and group by ... clauses, like here:
select clint_id, items_id, qty, ret, nvl(qty,0) - nvl(ret,0) rest
from (
select clint_id, items_id,
sum(case when trans_type = 1 then quantity end) qty,
sum(case when trans_type = 2 then quantity end) ret
from data group by clint_id, items_id )
order by clint_id, items_id
SQLFiddle demo
I have problem with LINQ Query in following scenario:
I have Activity and ActivityTeacher Two Table and List of Some Teachers.
Activity Table
ActivityID Date Class
1 4/4/2012 1
2 4/5/2013 2
3 4/6/2013 5
4 5/6/2013 2
5 5/16/2013 1
6 5/20/2013 8
7 5/21/2013 7
8 6/22/2013 6
9 8/10/2013 5
10 8/12/2013 4
ActivityTeacher Table
ActivityID TeacherID
1 2
1 3
1 4
2 6
3 6
3 6
3 4
2 5
4 2
4 3
4 6
5 8
5 7
5 6
6 6
6 7
6 9
6 10
6 1
6 2
7 2
7 8
7 9
7 10
8 3
8 4
8 6
8 7
9 10
9 3
9 2
10 1
10 2
List of Teachers={2,3,4}
Now I want to select records from Activity based on List of Teachers={2,3,4}
without using foreach loop.
The Activity entity should have a Teachers navigation property you can utilize:
context.Activities
.Where(x => listOfTeachers.Contains(x.Teachers.Select(t => t.TeacherId)));
If listOfTeachers contains the three IDs 2, 3, 4, this query should translate to SQL that is similar to the following:
select a.*
from Activity a
inner join ActivityTeacher at
on a.activityid = at.activityid
where at.teacherid in (2, 3, 4);