August 21 grow topic

1.a. check out the student's name table TB1 greater than 80 points in every subject with a SQL statement

select DISTINCT name from TB1 where name not in(select DISTINCT name from TB1 where fenshu<80);

b. an SQL statement queries a table TB1 secondary school students names and subjects greater than the number of gates 80 points

select name,COUNT(fenshu)  from TB1 group by name where fenshu>80;

c. check out the surname "Chang" in the name of student

select name from TB1 where name like '张%';

name kecheng fenshu

Joe Smith 81 Languages

Joe Smith Mathematics 75

John Doe 76 languages

John Doe mathematics 90

Wang Wu Chinese 81

Wang MATHEMATICS 100

 

2. Copy table, just copy the table structure, the original table: a new table name: b, and increases a field name is "goods_prc" numeric in the new table.

alter table b  add(goods_prc number);

select *,1 as goods_prc into b from a where 1=2;

3. Please explain the similarities and differences exists and IN, and the difference between the union and the union all

IN determine whether a given value or values ​​in the list subquery match. When the query in the first query table sub-query, and then look in the table and do a Cartesian product, screened in accordance with the conditions. Therefore, relatively small when the inner, IN faster.

Specify a subquery exists to detect the presence of the line. Traversing the outer loop, then look at the appearance of the record and there is no data in the same table. Matches will result into the result set.

UNION check out the results if the same, then go heavy. UNION ALL will show all the results, not heavy.  

4. The table has three C AB, implemented using SQL statements: Option A or Option B column A column when the column is greater than B, row select B column or C column Select B column when the column is greater than C.

select case
when a > b then
a
when b > a then
b
when b > c then
b
when b < c then
c
end
from table;

 

select (case when a>b then a else b end),(case when b>c then b esle c end) from table_name;

5. Establish a stored procedure that returns the number today is the first day of 2013.

select  add_months(trunc(sysdate),-(2019-2013)*12) - date'2013-01-01' from dual;

Please use your own good at languages ​​(VB priority)

1. Please write cycle, the data from 0 to 100, and then outputs?

int sum =0;
for (int i = 0; i <= 100; i++){
sum = sum + i;
}
System.out.println(sum);

2. Receive data from an interface, if more than 90, excellent output, greater than 60 to output a pass, fail or output

 

Guess you like

Origin www.cnblogs.com/whymoney1000/p/11391420.html