Home > Enterprise >  SQL Select top 100 columns be specific column names or indices
SQL Select top 100 columns be specific column names or indices

Time:11-16

This works to select top 100 columns, but it gives me all of the columns

select top 100 * from dw.test

This works, but it gives me endless rows,

select Slot, ID from dw.test

I need to select top 100 rows that only show these two columns Slot, ID

I cannot get it to work no matter how I try to combine them, Please help create this query. Thank you

CodePudding user response:

It's not clear to me which RDBMS is being used, but one of the following should work:

SELECT TOP(100) Slot, ID FROM dw.test;

Limit instead?

SELECT Slot, ID FROM dw.test LIMIT 100;

CodePudding user response:

try it

select TOP(100) Slot, ID from dw.test ORDER BY Slot, ID DESC
  •  Tags:  
  • sql
  • Related