Return Rows as per Quantity of Columns Value In SQL

I need to return as many rows as a qty column is telling me, but getting an error message
 		SELECT O.orderKey,U.lastname,U.firstname,LIP.qty
    	FROM orders O
    	inner join lineItems LI on LI.orderKey = O.orderKey
    	inner join lineitems_product LIP on LIP.lineitemKey = LI.lineitemKey 
    	inner join users U on U.userKey = O.userKey	
    	WHERE O.void <> 'Y' 
    	and LI.productID = 'GC'
    (SELECT number
    FROM master..spt_values 
    WHERE Type = 'P') as  n
WHERE t.qty > n.number

Open in new window

LVL 19
erikTsomikSystem Architect, CF programmer Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jim HornSQL Server Data DudeCommented:
>but getting an error message
An excellent idea would be to tell us what that error message is, especially if you can double-click on it, watch the cursor jump to the offending line, and also tell us what that line is.
Jim HornSQL Server Data DudeCommented:
Also your query does not specify how t and n are related.  JOIN, LEFT JOIN, CROSS JOIN, ...
erikTsomikSystem Architect, CF programmer Author Commented:
Msg 156, Level 15, State 1, Line 13
Incorrect syntax near the keyword 'SELECT'.
Msg 102, Level 15, State 1, Line 15
Incorrect syntax near ')'.
Active Protection takes the fight to cryptojacking

While there were several headline-grabbing ransomware attacks during in 2017, another big threat started appearing at the same time that didn’t get the same coverage – illicit cryptomining.

erikTsomikSystem Architect, CF programmer Author Commented:
i was  trying  to use this idea from the page which is what I need
Jim HornSQL Server Data DudeCommented:
>i was  trying  to use this idea
You missed the comma after T

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
erikTsomikSystem Architect, CF programmer Author Commented:
Thank you. what a silly mistake
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Query Syntax

From novice to tech pro — start learning today.