| |

VerySource

 Forgot password?
 Register
Search
View: 1258|Reply: 18

On the seat sorting problem! Online etc ... (.net)

[Copy link]

1

Threads

6

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-1-20 15:00:02
| Show all posts |Read mode
E.g
empno (work number) pay_mon (amount) busno (car number) seatno (seat number) status1 status2
1 200 8 1 Y OLD
2 200 8 2 Y OLD
3 200 8 3 Y OLD
4 160 8 4 Y OLD
5 160 8 5 Y OLD
6 100 8 6 N OLD
7 100 8 7 Y OLD
8 100 8 8 Y NEW
9 60 8 9 Y NEW
In the above table, if you want to delete the records of empno = 3, and then sort them by seatno, the seatno of status1 = N or staus2 = NEW remains unchanged!
Reply

Use magic Report

0

Threads

52

Posts

34.00

Credits

Newbie

Rank: 1

Credits
34.00

 China

Post time: 2020-1-29 12:54:01
| Show all posts
I do n’t understand. Do you want to count again?
thumbs up
Reply

Use magic Report

1

Threads

26

Posts

14.00

Credits

Newbie

Rank: 1

Credits
14.00

 China

Post time: 2020-1-29 13:54:01
| Show all posts
Write what kind of output you are willing to see in the end, what you said is not clear!
Reply

Use magic Report

1

Threads

6

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-1-29 18:09:01
| Show all posts
The final output is (the record of status1 = N is unchanged)
empno pay_mon busno seatno status1 status2
1 200 8 1 Y OLD
2 200 8 2 Y OLD
3 160 8 3 Y OLD
4 160 8 4 Y OLD
5 100 8 5 Y OLD
6 100 8 6 N OLD
7 100 8 7 Y NEW
8 60 8 8 Y NEW
Reply

Use magic Report

1

Threads

26

Posts

14.00

Credits

Newbie

Rank: 1

Credits
14.00

 Netherlands

Post time: 2020-1-29 23:18:01
| Show all posts
I do not know what you're talking about? The table data you gave above is too special, right? " It's all in order. Who do you want to sort by? Is the data of status1 = N or status2 = NEW keeping its original number of rows in the table? The following lines are moved forward in turn?

You'd better give the original data before sorting, and the output form you expect after, don't be too much, about 4 lines can express what you mean, more glances!
Reply

Use magic Report

1

Threads

6

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-1-30 08:54:01
| Show all posts
Initial table
empno (work number) pay_mon (amount) busno (car number) seatno (seat number) status1 status2
1 200 8 1 Y OLD
2 200 8 2 Y OLD
3 200 8 3 Y OLD
4 160 8 4 Y OLD
5 160 8 5 Y OLD
6 100 8 6 N OLD
7 100 8 7 Y OLD
8 100 8 8 Y NEW
9 60 8 9 Y NEW
After deleting empno = 3, the resulting table

empno pay_mon busno seatno status1 status2
1 200 8 1 Y OLD
2 200 8 2 Y OLD
4 160 8 3 Y OLD
5 160 8 4 Y OLD
7 100 8 5 Y OLD
6 100 8 6 N OLD
8 100 8 7 Y NEW
9 60 8 8 Y NEW
Reply

Use magic Report

0

Threads

52

Posts

34.00

Credits

Newbie

Rank: 1

Credits
34.00

 China

Post time: 2020-1-30 09:36:01
| Show all posts
Ha ha
Let me talk first
1 Can read all data into DS and then set the seatno number of all data to be processed (empno = 3) to -1 to update DS to the database
2 Spell sql directly If the amount of data is not large, the execution efficiency of complex nested sql statements will not be very low
Reply

Use magic Report

0

Threads

52

Posts

34.00

Credits

Newbie

Rank: 1

Credits
34.00

 Korea, Republic of

Post time: 2020-1-30 10:09:01
| Show all posts
Oh, I wrote it wrong 8
empno> 3
Ha ha
Reply

Use magic Report

1

Threads

6

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-1-30 10:27:01
| Show all posts
You forgot the record of status1 = N, its seatno is unchanged
Reply

Use magic Report

0

Threads

52

Posts

34.00

Credits

Newbie

Rank: 1

Credits
34.00

 China

Post time: 2020-1-30 13:18:01
| Show all posts
It ’s not reflected in the output that you give later. I think you said that the status2 is new. But it seems that the output you give also changes.
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list