SOS SQL 2005 How to make one column of data multiple

Updated on technology 2024-04-28
18 answers
  1. Anonymous users2024-02-08

    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.

  2. Anonymous users2024-02-07

    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.

  3. Anonymous users2024-02-06

    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.

  4. Anonymous users2024-02-05

    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.

  5. Anonymous users2024-02-04

    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;

  6. Anonymous users2024-02-03

    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.

  7. Anonymous users2024-02-02

    select name1 , name2 , name3 from biao

    union all

    select name4, name5,name6 from biao

    How many fields are there, and so on.

  8. Anonymous users2024-02-01

    Use union to assemble the data query results of each 3 columns

  9. Anonymous users2024-01-31

    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.

  10. Anonymous users2024-01-30

    Set it to become the primary key.

  11. Anonymous users2024-01-29

    Add a unique constraint

  12. Anonymous users2024-01-28

    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

  13. Anonymous users2024-01-27

    Upstairs is right, you don't combine one column, how can it be displayed in one column.

  14. Anonymous users2024-01-26

    Replace it directly, use the string function.

  15. Anonymous users2024-01-25

    If you want someone to help you solve the problem, learn to describe the problem clearly and don't waste everyone's time.

  16. Anonymous users2024-01-24

    Multiple columns? Multiple fields are, of course, multiple columns.

  17. Anonymous users2024-01-23

    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.

  18. Anonymous users2024-01-22

    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.

Related questions
4 answers2024-04-28

Click on this.

Server Name: Just enter a dot. >>>More

20 answers2024-04-28

The implementation method and detailed operation steps are as follows: >>>More

9 answers2024-04-28

The first way is to do a correlation query, which already has the answer. >>>More

14 answers2024-04-28

It would be like this when I was a kid. Eat bad stuff. And also. >>>More

16 answers2024-04-28

Since she said what she said, you have no future. Let it go!! >>>More