SQL Basic Statement

Source: Internet
Author: User

---restore content starts---

The query has several different job names:

Select distinct name from A;

GROUP BY:

There are now two table product and sales, the fields are as follows:

Tables:product

Field: ID (Product ID), name (product name)

Tables:sales

Fields: ID (Sales ID), PRODUCT_ID (Product ID), date (date), amount (sales quantity)

1, modify product D's product name is E

Update product set name=e where Name=d;

2, insert product name "Product E" product data;

Insert into table (product) field (products e);

3, delete the product name is "Product e" data;

Delete from product where Name = Product E;

4, for the period from 2014-1-1 to 2014-1-3, the number of daily sales of more than 110 products;

Select name from Product A, sales B where a.date > 2014.1.1 and < 2014.1.3 B.amount >110;

5. Search for the product name with the most sales volume;

Select Name from product A,sales b where amount=max (amount);

6, query the sum of each classification: query the total sales of each product;

Select sum (amount) from Product A, Sales b group by b.proudct_id;

7, query the total sales of more than 300 of the products;

Select ID Name from product a right join sales B where have sum (amount) >300;

---------------------------------------------------------

1, inquire how many products;

Select distinct Name from product;

2, the number of statistical products;

Select COUNT (distinct name) from product;

Common OptionsPersonal Classification
< Label style= "margin:0px 0px 2px 2px; Background:inherit; "for=" Editor_edit_apoptions_advancedpanel1_cklcategories_0 ">linux < Label style= "margin:0px 0px 2px 2px; Background:inherit; "for=" Editor_edit_apoptions_advancedpanel1_cklcategories_1 ">LR < Label style= "margin:0px 0px 2px 2px; Background:inherit; "for=" editor_edit_apoptions_advancedpanel1_cklcategories_2 ">sql < Label style= "margin:0px 0px 2px 2px; Background:inherit; "for=" Editor_edit_apoptions_advancedpanel1_cklcategories_3 ">UFT/QTP Computer knowledge
Publish Options

---restore content ends---

The query has several different job names:

Select distinct name from A;

GROUP BY:

There are now two table product and sales, the fields are as follows:

Tables:product

Field: ID (Product ID), name (product name)

Tables:sales

Fields: ID (Sales ID), PRODUCT_ID (Product ID), date (date), amount (sales quantity)

1, modify product D's product name is E

Update product set name=e where Name=d;

2, insert product name "Product E" product data;

Insert into table (product) field (products e);

3, delete the product name is "Product e" data;

Delete from product where Name = Product E;

4, for the period from 2014-1-1 to 2014-1-3, the number of daily sales of more than 110 products;

Select name from Product A, sales B where a.date > 2014.1.1 and < 2014.1.3 B.amount >110;

5. Search for the product name with the most sales volume;

Select Name from product A,sales b where amount=max (amount);

6, query the sum of each classification: query the total sales of each product;

Select sum (amount) from Product A, Sales b group by b.proudct_id;

7, query the total sales of more than 300 of the products;

Select ID Name from product a right join sales B where have sum (amount) >300;

---------------------------------------------------------

1, inquire how many products;

Select distinct Name from product;

2, the number of statistical products;

Select COUNT (distinct name) from product;

Common OptionsPersonal Classification
< Label style= "margin:0px 0px 2px 2px; Background:inherit; "for=" Editor_edit_apoptions_advancedpanel1_cklcategories_0 ">linux < Label style= "margin:0px 0px 2px 2px; Background:inherit; "for=" Editor_edit_apoptions_advancedpanel1_cklcategories_1 ">LR < Label style= "margin:0px 0px 2px 2px; Background:inherit; "for=" editor_edit_apoptions_advancedpanel1_cklcategories_2 ">sql < Label style= "margin:0px 0px 2px 2px; Background:inherit; "for=" Editor_edit_apoptions_advancedpanel1_cklcategories_3 ">UFT/QTP Computer knowledge
Publish Options

SQL Basic Statement

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.