troubleshooting Question

Return Rows as per Quantity of Columns Value In SQL

Avatar of erikTsomik
erikTsomikFlag for United States of America asked on
Microsoft SQL ServerSQL
6 Comments1 Solution106 ViewsLast Modified:
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
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros