Home > database >  How to sort by two fields, SQL EXCLE can ah. The following
How to sort by two fields, SQL EXCLE can ah. The following

Time:11-09

Want to sort by XL sales and sup_nam suppliers,
Is this table sorting effect

Statement is
The select item_no, item_name, xl, item_clsname sup_name from temp_mxp_topxx k group by sup_name, item_no, item_name,
XL, item_clsname having item_no in (select top 30 m.i tem_no from temp_mxp_topxx m where Keith up_name=Margaret spellings up_name
The order by XL desc
) order by XL, sup_name
Effect is
Not line,
The great spirit of SQL, maybe EXCLE could overshadow SQL? !

CodePudding user response:

The select item_no, item_name, xl, item_clsname sup_name from temp_mxp_topxx k group by sup_name, item_no, item_name,
XL, item_clsname having item_no order by XL, sup_name
So try

CodePudding user response:

Don't understand what you mean,
Your SQL, the order by XL, sup_name
Sort by XL, and then press sup_name sorting,

XL is there so much 12, of course, have to row together ah,
Queue up to turn sup_name,

If you want to sup_name priority, it should be: the order by sup_name, XL

CodePudding user response:

Thank you upstairs to pay tribute, although an error, I again churning churning replaced under the back of the two fields is a step in the right order, although I don't know is why,,,
The select item_no, item_name, xl, item_clsname sup_name from temp_mxp_topxx k group by sup_name, item_no, item_name,
XL, item_clsname having item_no in (select top 30 m.i tem_no from temp_mxp_topxx m where Keith up_name=Margaret spellings up_name
The order by XL desc
) order by sup_name, XL

CodePudding user response:

Thank you again for the moderator,

CodePudding user response:

refer to the second floor of gypsy song response:
don't understand what you mean,
Your SQL, the order by XL, sup_name
Sort by XL, and then press sup_name sorting,

XL is there so much 12, of course, have to row together ah,
Queue up to turn sup_name,

If you want to sup_name priority, it should be: the order by sup_name, XL

To bosses under the guidance of how to keep the temporary table I built, the SQL server a reconnection is not the tempxxx table, this is a select * into.... Come, I know that Oracle create table as... Table,

CodePudding user response:

reference 5 floor qq_40104078 reply:
Quote: refer to the second floor of the gypsy song response:
don't understand what you mean,
Your SQL, the order by XL, sup_name
Sort by XL, and then press sup_name sorting,

XL is there so much 12, of course, have to row together ah,
Queue up to turn sup_name,

If you want to sup_name priority, it should be: the order by sup_name, XL

To bosses under the guidance of how to keep the temporary table I built, the SQL server a reconnection is not the tempxxx table, this is a select * into.... Come, I know that Oracle create table as... Table,


 - 1 temporary table next time can't use, can only be used for this session 
SELECT *
INTO # TMP
The FROM tableName

- 2 global temporary tables all connections can be used, but to restart the SQL server or delete or create global temporary table disconnected can no longer use
SELECT *
INTO # # tmp2
The FROM tableName

- three regular tables, permanent
SELECT *
INTO tmp3
The FROM tableName

Suggest you according to the need, choose 2 or 3,

CodePudding user response:

1/f, you can
  • Related