• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

How to change fileds number using SQL statment

 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, Folks,

I have a table like this

leaseno name percnetage
1 edgy 100
1 ed 50
1 micale 30
2 kathy 70
2 nancy 78
3 tony 40

Can I use SQL to gneragte a table like this accorfing the above
note, the size of the field is dynamic depends on the number of records.

leasno name1 percnetage1 name2 percnetage2 name3 percnetage3
1 edgy 100 ed 50 micale 30
2 kathy 30 nancy 78 null null
3 tony 40 null null null null

Thank you

Chaohua
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It looks like you are trying to do a crosstab query. Usually the table would have been designed as third normal form where you would have had a one-to many relationship between lease number in one table(one side) and the other data in the other table(many side).

Crosstab queries are difficult and some Databases don't support it.

Mark
 
Ranch Hand
Posts: 1143
1
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Chaohua,
Search the Ask Tom Web site for the term "pivot".

Good Luck,
Avi.
 
reply
    Bookmark Topic Watch Topic
  • New Topic