GRUPOS DE DISCUSSÃO PROFISSIONAL
WINDEV
,
WEBDEV
e
WINDEV Mobile
Inicio
|
Mensagens recentes
|
Conecte-se...
|
Disconnect
|
Português
Inicio
→
WINDEV 2024
→
How to retrive values based on Slabs
How to retrive values based on Slabs
Iniciado por Yogi Yang, out., 16 2017 2:31 PM - 3 respostas
Conecte-se…
Yogi Yang
#1
Publicado em outubro, 16 2017 - 2:31 PM
Hello,
I have a table whose structure is:
p_product_id p_weight p_rate
This table contains following data:
p_product_id p_weight p_rate 1 0.250 1 1 0.500 4 1 0.750 7 1 0.900 7.5 1 1.000 10 2 0.250 2 2 0.500 3 2 1.150 10.5 3 0.700 6.5 3 0.900 7.5
Now when a user enters Weight I need to find the rate applicable.
So if user enters weight of 0.600 then based on the product selected the rate applicable is that of 0.750 that is 7
What query should I use for retrieving this rate?
TIA
Denunciar
0
0
Paulo Oliveira
#2
Publicado em outubro, 16 2017 - 3:00 PM
Not tested but try something like this:
select s.p_rate from your_table s
where s.p_product_id=the produtct you need
and s.p_weight = (select min(w.p_weight) from from your_table w
where s.p_product_id=w.p_product_id and
w.p_weight>= your_input weight)
Denunciar
0
0
Sascha77
#3
Publicado em outubro, 16 2017 - 3:01 PM
Yogi,
if your logic needs to be the perfect match or take the next higher weight this query should do the trick.
select * from table
where p_weight >= %1
and p_product_id = 'ProductID'
order by p_weight asc
limit 1;
cheers,
Sascha
Denunciar
0
0
Yogi Yang
#4
Publicado em outubro, 17 2017 - 6:10 AM
Sascha,
Quote
Sascha77
if your logic needs to be the perfect match or take the next higher weight this query should do the trick.
select * from table
where p_weight >= %1
and p_product_id = 'ProductID'
order by p_weight asc
limit 1;
That is great. It does the trick for me! And it works like a charm.
Thanks for this simple and workable solution.
Regards,
Denunciar
0
0
→ Voltar para WINDEV 2024
WINDEV 2024
WEBDEV 2024
WINDEV Mobile 2024
WINDEV (versões anteriores)
Français
English
Español
Portuguesa
Fermer cette fenêtre
Tipo de Pesquisa
Apenas tópicos
Todas as mensagens
Período de pesquisa
Qualquer momento
Última hora
Últimas 24 horas
Semana passada
Mês passado
Ano passado
Cancelar
Pré-visualização da sua mensagem
Adicionar imagem
Importar uma imagem de uma URL
Enviar uma imagem a partir do seu disco
Deixe um ficheiro ou clique em "Procurar ..."
ou
Cancelar
0%
WLanguage
SQL
XML, HTML
JAVA, Javascript
Texto