Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

vitinho.vitor

[Resolvido] Divisão

Recommended Posts

Boa tarde!!

 

Estou com uma dúvida, preciso dividir o total pela quantidade e ver se o valor é menos que...

reciso fazer isso com todos os registros.

Tenteis fazer assim:

SELECT id, (`total hiperm` /  `qtde hiperm`) AS total
FROM pedidos
WHERE  `total` <=  '59'

 

Mas não me retornou exatamente o que eu queria.

Tem muitos resultados NULL e vários também com valores mais altos que 59.

 

O que tem de errado.

 

Obrigado

Vitor

Compartilhar este post


Link para o post
Compartilhar em outros sites

A tabela tem muitas colunas então mostrarei as mais importantes:

id

...

qtde hiperp

qtde hiperm //essa é a quantidade

qtde hiperg

qtde hipereg

...

...

...

total hiperp

total hiperm //dividir esta pela quantidade

total hiperg

total hipereg

...

total //não é essa coluna que estou querendo

...

...

...

 

Obrigado

Vitor

 

SHOW CREATE

 

CREATE TABLE `pedidos` (

`id` int(10) NOT NULL AUTO_INCREMENT,

`id_user` int(10) NOT NULL,

`id_est` int(10) NOT NULL,

`data` varchar(20) COLLATE latin1_general_ci NOT NULL,

`date` datetime NOT NULL,

`data_faturamento` datetime NOT NULL,

`status` varchar(20) COLLATE latin1_general_ci NOT NULL,

`prazo entrega` varchar(20) COLLATE latin1_general_ci NOT NULL,

`qtde minip` varchar(4) COLLATE latin1_general_ci NOT NULL,

`qtde praticop` varchar(4) COLLATE latin1_general_ci NOT NULL,

`qtde megap` varchar(4) COLLATE latin1_general_ci NOT NULL,

`qtde hiperp` varchar(4) COLLATE latin1_general_ci NOT NULL,

`qtde econ notp` varchar(4) COLLATE latin1_general_ci NOT NULL,

`qtde mega notp` varchar(4) COLLATE latin1_general_ci NOT NULL,

`qtde granelp` varchar(4) COLLATE latin1_general_ci NOT NULL,

`qtde minim` varchar(4) COLLATE latin1_general_ci NOT NULL,

`qtde praticom` varchar(4) COLLATE latin1_general_ci NOT NULL,

`qtde megam` varchar(4) COLLATE latin1_general_ci NOT NULL,

`qtde hiperm` varchar(4) COLLATE latin1_general_ci NOT NULL,

`qtde econ notm` varchar(4) COLLATE latin1_general_ci NOT NULL,

`qtde mega notm` varchar(4) COLLATE latin1_general_ci NOT NULL,

`qtde granelm` varchar(4) COLLATE latin1_general_ci NOT NULL,

`qtde minig` varchar(4) COLLATE latin1_general_ci NOT NULL,

`qtde praticog` varchar(4) COLLATE latin1_general_ci NOT NULL,

`qtde megag` varchar(4) COLLATE latin1_general_ci NOT NULL,

`qtde hiperg` varchar(4) COLLATE latin1_general_ci NOT NULL,

`qtde econ notg` varchar(4) COLLATE latin1_general_ci NOT NULL,

`qtde mega notg` varchar(4) COLLATE latin1_general_ci NOT NULL,

`qtde granelg` varchar(4) COLLATE latin1_general_ci NOT NULL,

`qtde minieg` varchar(4) COLLATE latin1_general_ci NOT NULL,

`qtde praticoeg` varchar(4) COLLATE latin1_general_ci NOT NULL,

`qtde megaeg` varchar(4) COLLATE latin1_general_ci NOT NULL,

`qtde hipereg` varchar(4) COLLATE latin1_general_ci NOT NULL,

`qtde econ noteg` varchar(4) COLLATE latin1_general_ci NOT NULL,

`qtde mega noteg` varchar(4) COLLATE latin1_general_ci NOT NULL,

`qtde graneleg` varchar(4) COLLATE latin1_general_ci NOT NULL,

`qtde granel notp` varchar(4) COLLATE latin1_general_ci NOT NULL,

`qtde granel notm` varchar(4) COLLATE latin1_general_ci NOT NULL,

`qtde granel notg` varchar(4) COLLATE latin1_general_ci NOT NULL,

`qtde granel noteg` varchar(4) COLLATE latin1_general_ci NOT NULL,

`qtde total` varchar(6) COLLATE latin1_general_ci NOT NULL,

`total minip` varchar(10) COLLATE latin1_general_ci NOT NULL,

`total praticop` varchar(10) COLLATE latin1_general_ci NOT NULL,

`total megap` varchar(10) COLLATE latin1_general_ci NOT NULL,

`total hiperp` varchar(10) COLLATE latin1_general_ci NOT NULL,

`total econ notp` varchar(10) COLLATE latin1_general_ci NOT NULL,

`total mega notp` varchar(10) COLLATE latin1_general_ci NOT NULL,

`total granelp` varchar(15) COLLATE latin1_general_ci NOT NULL,

`total minim` varchar(10) COLLATE latin1_general_ci NOT NULL,

`total praticom` varchar(10) COLLATE latin1_general_ci NOT NULL,

`total megam` varchar(10) COLLATE latin1_general_ci NOT NULL,

`total hiperm` varchar(10) COLLATE latin1_general_ci NOT NULL,

`total econ notm` varchar(10) COLLATE latin1_general_ci NOT NULL,

`total mega notm` varchar(10) COLLATE latin1_general_ci NOT NULL,

`total granelm` varchar(15) COLLATE latin1_general_ci NOT NULL,

`total minig` varchar(10) COLLATE latin1_general_ci NOT NULL,

`total praticog` varchar(10) COLLATE latin1_general_ci NOT NULL,

`total megag` varchar(10) COLLATE latin1_general_ci NOT NULL,

`total hiperg` varchar(10) COLLATE latin1_general_ci NOT NULL,

`total econ notg` varchar(10) COLLATE latin1_general_ci NOT NULL,

`total mega notg` varchar(10) COLLATE latin1_general_ci NOT NULL,

`total granelg` varchar(15) COLLATE latin1_general_ci NOT NULL,

`total minieg` varchar(10) COLLATE latin1_general_ci NOT NULL,

`total praticoeg` varchar(10) COLLATE latin1_general_ci NOT NULL,

`total megaeg` varchar(10) COLLATE latin1_general_ci NOT NULL,

`total hipereg` varchar(10) COLLATE latin1_general_ci NOT NULL,

`total econ noteg` varchar(10) COLLATE latin1_general_ci NOT NULL,

`total mega noteg` varchar(10) COLLATE latin1_general_ci NOT NULL,

`total graneleg` varchar(15) COLLATE latin1_general_ci NOT NULL,

`total granel notp` varchar(10) COLLATE latin1_general_ci NOT NULL,

`total granel notm` varchar(10) COLLATE latin1_general_ci NOT NULL,

`total granel notg` varchar(10) COLLATE latin1_general_ci NOT NULL,

`total granel noteg` varchar(10) COLLATE latin1_general_ci NOT NULL,

`cond_pgto` varchar(15) COLLATE latin1_general_ci NOT NULL,

`sol_desc_ger` varchar(15) COLLATE latin1_general_ci NOT NULL,

`sol_desc_adm` varchar(15) COLLATE latin1_general_ci NOT NULL,

`desc_rep` varchar(15) COLLATE latin1_general_ci NOT NULL,

`desc_ger` varchar(15) COLLATE latin1_general_ci NOT NULL,

`desc_adm` varchar(15) COLLATE latin1_general_ci NOT NULL,

`valor_desc_rep` varchar(15) COLLATE latin1_general_ci NOT NULL,

`valor_desc_ger` varchar(15) COLLATE latin1_general_ci NOT NULL,

`valor_desc_adm` varchar(15) COLLATE latin1_general_ci NOT NULL,

`total` varchar(15) COLLATE latin1_general_ci NOT NULL,

`bruto` varchar(15) COLLATE latin1_general_ci NOT NULL,

`comissao` varchar(6) COLLATE latin1_general_ci NOT NULL,

`obs` text COLLATE latin1_general_ci NOT NULL,

PRIMARY KEY (`id`)

) ENGINE=MyISAM AUTO_INCREMENT=375 DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.