-
select sum(case when brand=.'Ruyi card'then 1 else 0 end ) Ruyi card ,sum(case when brand='Long-distance passes'then 1 else 0 end ) long distance ,sum(case when brand='New forces'then 1 else 0 end ) new forces , the name of the outlet and the name of the owner.
from table
group by Location Name Store owner's name.
-
Select outlet name, store owner name, sum(case brand when'Ruyi card'then 1 else 0 end) Ruyi card, sum(case brand when'New forces'then 1 else 0 end) New Forces, - not all written, note that the last line does not add a comma.
from table name group by outlet name, store owner name.
If you want to save this dataset to the table, then I believe I don't need to say more, I really won't just f1, inserting the dataset into the table is an insert.
-
Agree with the upstairs.
select
The name of the outlet, the name of the owner, sum(case brand when'Ruyi card' then 1 else 0 end) as 'Ruyi card', sum(case brand when'Long-distance passes' then 1 else 0 end) as 'Long-distance passes', sum(case brand when'New forces' then 1 else 0 end) as 'New forces'
from the table name.
group by Location Name Store owner's name.
-
Positive rolling. select name,sum(case when type=1 then 1 else 0 end) as type:year:a,sum(case when type=2 then 1 else 0 end) as type:b,sum(case when type=3 then 1 else 0 end) as type:c,count(*)as total.
from table.
group by name.
-
Suppose your table is Fushan test12(name,type), then the SQL statement for the following is as follows;
select name as "The name is a letter",max(case when type=1 then 1 else 0 end) as "Type A",max(case when type=2 then 1 else 0 end) as "Class Lack Zen Medium B",max(case when type=3 then 1 else 0 end) as "Type C",count(*)as "Total" from test12 t group by name;
-
In what program is it used?
1.Use name1, name2, name3
name4 name5 name6
Give li style in CSS: line-hight:10px;
2.Use. 3.Use.
-
select name1 , name2 , name3 from biao
union all
select name4, name5,name6 from biao
How many fields are there, and so on.
-
Use union to assemble the data query results of each 3 columns
-
The unqiue constraint is used to enforce the uniqueness of non-primary key columns, allowing for the presence of null values (which should be only one).
Alter table tablename add constraint u store unique nonclustered (column name).
where u store is the name given to the constraint.
-
Set it to become the primary key.
-
Add a unique constraint
-
If a1, a2, a3 are all string types:
select a1+a2+a3 as col from tbl if a4 is of other type:
select a1+a2+a3+cast(a4 as varchar(20)) as col from tbl
-
Upstairs is right, you don't combine one column, how can it be displayed in one column.
-
Replace it directly, use the string function.
-
If you want someone to help you solve the problem, learn to describe the problem clearly and don't waste everyone's time.
-
Multiple columns? Multiple fields are, of course, multiple columns.
-
To give you an example:
A and B fields:
Sort them:
order by a,b
Results: 1,3
4,3 Explanation:
Sort by field a first, and get 1,1,2,4
If the A field is the same, sort by the B field: 1,3;1,4;
The b field is only used when the A field is the same.
The same logic is true in group by.
This logic is common across all databases.
-
You can convert the character type first and then add it.
select id,cast(col1 as varchar) +'~'+ cast(col2 as varchar) as col from your table.
Click on this.
Server Name: Just enter a dot. >>>More
The implementation method and detailed operation steps are as follows: >>>More
The first way is to do a correlation query, which already has the answer. >>>More
It would be like this when I was a kid. Eat bad stuff. And also. >>>More
Since she said what she said, you have no future. Let it go!! >>>More