SQL classification summary, SQL introduction and classification

Updated on technology 2024-04-29
4 answers
  1. Anonymous users2024-02-08

    Standard answer: select ,,sum(case when use status=.)'In use'then 1 else 0 end) in use, sum(case when use status='Unused'then 1 else 0 end) is not used.

    from a,b where

    group by ,

  2. Anonymous users2024-02-07

    select Table A*, Table BIn use, Table BUnused

    from table a left join

    select dc_id,sum( case dc_name when 'In use'then 1 else 0 end ) as in use, sum( case dc name when'Unused'then 1 else 0 end ) as unused.

    from Table B

    group by dc_id

    as table bon table = table.

  3. Anonymous users2024-02-06

    -> Test data: @a

    declare @a table (dc_id varchar(2),dc_name varchar(3))

    insert into @a

    select 'a1','aaa' union all

    select 'a2','aab'

    Test data: @b

    declare @b table (dp_id varchar(2),dc_id varchar(2),use_status varchar(6))

    insert into @b

    select 'b1','a1','In use' union all

    select 'b2','a1','Unused' union all

    select 'b3','a2','In use'

    select, unused = sum(case when ='Unused' then 1 else 0 end)

    Use = sum(case when ='In use' then 1 else 0 end)

    from @a a

    inner join @b b on =

    group by , dc id dc name is not used.

    a1 aaa 1 1

    a2 aab 0 1

    The number of rows affected is 2).

  4. Anonymous users2024-02-05

    SQL (Structured Query Language) is a standard computer language used to access and process databases. A programming language that operates relational databases, and defines a uniform standard for operating all relational databases.

    Universal grammar

    SQL statements can be written on a single line or multiple linesEnds with a semicolon

    It's not case-sensitive, but uppercase is recommended for keywords.

    Notes:Single-line comments: - Comment content (-- must be followed by a space) (You can also use comment content under MySQL).

    Multi-line comments: Comments *

    SQL classification

    DDL (Data Definition Language): A data definition language used to define database objects, such as databases, tables, and columns.

    Data Manipulation Language (DML) is a data manipulation language used to add, delete, and modify data in tables in a database.

    Data Query Language (DQL) is used to query the records (data) of tables in a database

    Data Control Language (DCL) is used to define the access and security levels of databases, and to create users.

    Query all databases

    Create a database

    Delete the database

    Use databases

    After the database is created, to create a table in the database, you must first specify which database to operate in, and then you need to use the database.

    View the database currently in use

    Manipulating a table is to add, create, retrieve, update, and delete a table.

    Query the names of all tables in the current database

    Query the table structure

    Create a table

    MySQL supports several types and can be divided into three categories:

    Delete the table

    Determine whether a table exists when you delete a table

    Change the table name

    Add a column

    Modify the data type

    Modify the column name and data type

    Delete columns

    Add, delete, or update data is performed.

    Add data to the specified column

    Add data to all columns

    Add data in bulk

    Modify table data

    Deletion of data

Related questions
9 answers2024-04-29

Add the field status to varchar(10) in the database table

update database table name set status = from database table name inner join temporary table name b on database table name. qh = and database table name. tel = >>>More

5 answers2024-04-29

With a view or an index.

create index >>>More

6 answers2024-04-29

1. Extensiveness: Any database based on SQL language may be attacked, and many developers do not conduct normative verification and detection of the values received from input parameters, web forms, cookies, etc. when writing web applications, and SQL injection vulnerabilities usually occur. >>>More

10 answers2024-04-29

First, if it is an oracle database and it has just been deleted, you can execute the following statement: >>>More

5 answers2024-04-29

Of course; Just use the row to the column.

Static writing. select unit,sum(case when year(time)=2005 and datepart(q,time)=1 then value else 0 end) as 2005 a quarter,sum(case when year(time)=2005 and datepart(q,time)=2 then value else 0 end) as 2005 a quarter ,.. >>>More