SQL One row becomes more than 10 columns

Updated on workplace 2024-04-11
20 answers
  1. Anonymous users2024-02-07

    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.

  2. Anonymous users2024-02-06

    select name1 , name2 , name3 from biao

    union all

    select name4, name5,name6 from biao

    How many fields are there, and so on.

  3. Anonymous users2024-02-05

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

  4. Anonymous users2024-02-04

    select Province, Number, Name, Phone1 from table.

    union all

    select Province, Number, Name, Mobile2 as Mobile1 from table.

    union all

    select Province, Number, Name, Phone3 as Phone1 from table.

    Note: The above query is not sorted.

  5. Anonymous users2024-02-03

    select a.* from

    select province, number, name, phone number1 from table name union all

    select Province, Number, Name, Phone2 as Phone1 from Table Name.

    union all

    select Province, Number, Name, Phone3 as Phone1 from Table Name) as a

    order by a.Province, ANo., aName.

  6. Anonymous users2024-02-02

    Replace it directly, use the string function.

  7. Anonymous users2024-02-01

    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.

  8. Anonymous users2024-01-31

    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;

  9. Anonymous users2024-01-30

    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.

  10. Anonymous users2024-01-29

    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.

  11. Anonymous users2024-01-28

    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.

  12. Anonymous users2024-01-27

    select name, (case when subject=mathematics then score end) as mathematics, (case when subject=language then score end) as language, (case when subject=english then score end) as english from table name.

  13. Anonymous users2024-01-26

    select name, decode(subject, language, fraction) as language, decode(subject, mathematics, fraction) as mathematics, decode(subject, english, fraction) as english.

    from indicates group by name.

  14. Anonymous users2024-01-25

    I also learned about databases this semester, and I didn't understand it, but I just came to complain, hehe, I'm sorry.

  15. Anonymous users2024-01-24

    Select Name, AFraction [mathematics], bFraction [language], cFractions, from table

    left outer join

    select name, score from table where subject='Mathematics')a on table.Name=aName.

    left outer join

    select name, score from table where subject='Language')b on table.Name=b.Name.

    left outer join

    select name, score from table where subject='English')c on table.Name = cName.

    order by name.

  16. Anonymous users2024-01-23

    select name, math=sum(case when subject='Mathematics'then score), language=sum(case when subject='Language'then score), English = sum(case when subject='English'then score) group by name.

    Try it, so let's do it.

  17. 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.

  18. Anonymous users2024-01-21

    - It's very simple.,The following passed the SQL2005 test.,Landlord please see:

    create table #t(a int,b int,c int,d int)

    insert #t

    select 1, 2, 3, 4 union allselect 5, 6, 7, 8

    select a,b,c,0 as d from #tunion

    select a,b,0 as c,d from #t

  19. Anonymous users2024-01-20

    You also give each data rule that becomes multiple rows of data, and I don't know how to help you, hehe.

  20. Anonymous users2024-01-19

    I can see some patterns, but I still don't understand how you want to change.

Related questions
4 answers2024-04-11

Positive: Hobbies are the best teachers of human beings, and we should strive for them. >>>More

5 answers2024-04-11

Arguments against the side:Our position is, "Love one line, do one line". >>>More

11 answers2024-04-11

When using the input method, click the "Left Hook" icon in the lower right corner to complete the carriage return line wrapping operation.

4 answers2024-04-11

It can be calculated according to your year of birth.

6 answers2024-04-11

1. First of all, open the original document and click "Options" in the upper left corner. >>>More