-
I'm not a master, I just know a little SQL statement, I wrote a SQL statement, I want to learn SQL with you (I wrote SQL Server statements, if it's other databases, it may be a little different).
select employees. Name, Fire Protection System = case when Project Name ='Fire protection system'Then file a case, else'0'end, anti-theft system =case when item name ='Anti-theft system'Then file a case, else'0'end, waterproofing system =case when item name ='Waterproofing system'Then file a case, else'0'end, water system=case when itemname='Piped water system'Then file a case, else'0'end, anti-wolf system =case when item name ='Anti-wolf system'Then file a case, else'0' end
from(select employee. Name, project name, employee number, number of hours filed.
from(select employee. Name, item. Project name.
from Projects, Staff.
where employees. Number = Item. Item No. *I think your project and staff both tables are made by employees. Number and item. The item number is associated, so it is written as such
a, project load.
where Project load. Item No. = Project. Item number *Same as above*
bgroup by Staff. Name, case when item name ='Fire protection system'Then file a case, else'0'end, case when project name ='Anti-theft system'Then file a case, else'0'end, case when project name ='Waterproofing system'Then file a case, else'0'end, case when project name ='Piped water system'Then file a case, else'0'end, case when project name ='Anti-wolf system'Then file a case, else'0' end
I don't know if it's right or not, but I hope that the database master can give me some advice.
-
And then look at the research.
If you really don't understand it, ask me again.
-
It is estimated that since the project is not fixed, the temporary table created will also be created with a stored procedure.
-
Temporary tables can be created, but they are not easy to create because the items are not fixed.
-
The type of birthday column and party member column.
It is a character type and a date with quotation marks' '
The digital type is not needed.
-
There are many methods, nested search and join search, especially join search, which is quite the same as merging two tables into one table, a statement is written to the end, nested search is also good, query efficiency is high, the main problem is... Give some practical conditions and requirements, and you ask questions like this, only to see the forest but not the trees.
-
You can try it.
select a,b,c from table1union all
select a, b, c from table2: Note that the field type of select must be the same for the two tables.
-
List the table structure, and then describe the requirements.
-
1 All correct: The answer is this.
insert into table2 select max(autoid),userid,title from table1 group by userid,title
-
Do you want the result to be 2 tables of records displayed in a result set select * from t1
union all
select * from t2
-
select * from t1
unionselect * from t2
order by companyid
Hehe, a simple external connection between two tables, I hope it can help you.
-
I can only say simply:
1.Material dimension table: The main Wu Chong is to record the material of the mausoleum.
2.Picking flow table: A record of each picking.
What can be divided into material properties should be divided into that dimension table as much as possible. Reduce the amount of data in the flow meter.
The above is a personal opinion.
-
Since the tables in the database are all in two-dimensional format, this is what we call a relational database.
In fact, to put it bluntly, it is the operation of rows and columns, of course, including the operation of tables, and some syntax keywords are given on the first floor.
Additions, deletions, and changes are all column-based.
Deleting, creating, and modifying tables are all for tables.
As long as you understand the relationship between structure and content, and then make more examples, you will be able to SQL.
-
insert: increment
update: Changed
delete: Deletes the record.
truncate: Same as above, but in a different way, this faster drop: delete the table.
create: create.
alter: changes the structure of the table.
This question requires 10 points.
First, use the left join to completely find out the 1 table, then use the right join to completely find out the 2 tables, and finally merge the results. >>>More
create table [dbo].[Employee Data Sheet] (Number] [Char] (10) Collate Chinese taiwan stroke ci as null, Name] [Char] (10) Collate Chinese taiwan stroke ci as null, Gender] [Char] (10) Collate Chinese taiwan stroke ci as null, Department] [char] (10) collate Chinese taiwan stroke ci as null, salary] [char] (10) collate Chinese taiwan stroke ci as null >>>More
The above is based on the id of your table, but it is true that if there is no id, it feels more difficult to delete it directly, but it can be done directly by a rogue method. >>>More
The first way is to do a correlation query, which already has the answer. >>>More