Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
1.3 kB
1
Indexable
Never
                SELECT  
	                stk.storeno                                                                     AS storeno,
	LEFT(prd.name, 38)                                                                              AS name,                                      
	trim(stk.prdno)                                                                                       AS prdno,
	stk.grade                                                                                       AS grade,
	ROUND(((stk.qtty_varejo + stk.qtty_atacado) / 1000),0)                                          AS qtd_Grade,
	GROUP_CONCAT(TRIM(prdbar.barcode))                                                              AS barcode,
	IFNULL(prp.cost,0)																				AS prc_custo,
	prd.mfno_ref                                                                                    AS referencia
FROM sqldados.stk 
INNER JOIN sqldados.prd ON prd.no = stk.prdno
INNER JOIN sqldados.prdbar ON prdbar.prdno = stk.prdno AND prdbar.grade = stk.grade
LEFT JOIN sqldados.prp ON stk.storeno = prp.storeno AND stk.prdno = prp.prdno 
WHERE stk.storeno=:storeno AND stk.qtty_varejo + stk.qtty_atacado > 0
AND (INSTR(:clno, LEFT(prd.clno,1)) > 0 OR INSTR(:clno, 0) > 0)
GROUP BY stk.prdno,stk.grade
Leave a Comment