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 T.* 
 	FROM 
 	
 	(
 		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'
    )T
    (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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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 HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
>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.
0
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
Also your query does not specify how t and n are related.  JOIN, LEFT JOIN, CROSS JOIN, ...
0
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 ')'.
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

erikTsomikSystem Architect, CF programmer Author Commented:
i was  trying  to use this idea from the page which is what I need
http://stackoverflow.com/questions/25013503/return-rows-as-per-quantity-of-columns-value-in-sql
0
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
>i was  trying  to use this idea
You missed the comma after T
0

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
0
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.