Banku (Shanghai) Business Consulting Co., Ltd.

Source: Internet
Author: User

A table named Student contains the following fields: id, classid, name, birth, remark

1. Insert a record: classid = 2 name = Zhang San birth = 1982-07-19;

Answer: insert into student (classid, name, birth) values (2, 'zhang san', '2017-07-19 ')

 

2. Select all students whose classid is 4;

Answer: select * from student where classid = 4

 

3. query all persons with the Year of birth greater than 1976;

Answer: select * from student where birth> '123'

 

4. query the number of people who have been born in each class for more than 1976 years;

Answer: select classid, count (*) as number from student where birth> '123' group by classid

 

5. query the number of students in all classes;

Answer: select classid, count (*) as total from student group by classid

 

6. query all records containing "Plans" in the REMAK;

Answer: select * from student where remark like '% scheduler %'

 

7. Improve SQL efficiency;

Answer: In ASP,

  • Use JOIN to write complex SQL statements instead of a bunch of SQL statements: Query all data at a time;
  • Use the UPDATE statement instead of rs. update ();
  • Batch Processing of SQL statements is more efficient than executing one sentence;
  • The where clause first considers the index;
  • Avoid using large fields such as TEXT: Large execution efficiency is also high in the database;

Other aspects:

  • Replacing temporary tables with embedded views: temporary tables consume a lot of memory and perform a lot of I/O operations;
  • Avoid using left join and NULL values, Use inner join, and set the field cannot be NULL;
  • Use indexes;
  • Use the partition view;
  • Use the trigger to run the stored procedure to another statistical table;

 

8. The code is used to print the triangle;

Answer:

 

Code
Private void PascalTriangle (int number)
{
Int I, j, n, m;
N = number;
Int [,] a = new int [20, 20];

For (I = 0; I <n; I ++)
{
A [I, 0] = 1;
A [I, I] = 1;
}

For (I = 2; I <n; I ++)
{
For (j = 1; j <I; j ++)
{
A [I, j] = a [I-1, j-1] + a [I-1, j];
}
}

For (I = 0; I <n; I ++)
{
For (m = 1; m <n-I; m ++)
{
Response. Write ("& nbsp ;");
}

For (j = 0; j <= I; j ++)
{
Response. Write (a [I, j]. ToString ());
Response. Write ("& nbsp ;");
}

Response. Write ("<br> ");
}
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.