question

ErlichBachman avatar image
ErlichBachman asked

Select without From in sql server

Can smn explain me how this query works without FROM, having just SELECT here:

select code, speed, ram, price, screen

from laptop where exists (

select 1 x

from (


select v, rank()over(order by v) rn

from ( select cast(speed as float) sp, cast(ram as float) rm,

cast(price as float) pr, cast(screen as float) sc

)l unpivot(v for c in (sp, rm, pr, sc))u

)l pivot(max(v) for rn in ([1],[2],[3],[4]))p

where [1]*2 <= [2] and [2]*2 <= [3] and [3]*2 <= [4]

)

1.png

This is the answer for this task :

From the Laptop table, select rows fulfilling the following condition:
the values of the speed, ram, price, and screen columns can be arranged in such a way that each successive value exceeds two or more times the previous one.
Note: all known laptop characteristics are greater than zero.
Output: code, speed, ram, price, screen.

sql serverselectquestions
1.png (12.2 KiB)
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
MikeyBronowski avatar image
MikeyBronowski answered
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.