FORUMS PROFESSIONNELS
WINDEV
,
WEBDEV
et
WINDEV Mobile
Accueil
|
Messages récents
|
Connexion
|
Déconnexion
|
Français
Accueil
→
WINDEV 2024
→
How to retrive values based on Slabs
How to retrive values based on Slabs
Débuté par Yogi Yang, 16 oct. 2017 14:31 - 3 réponses
Connectez-vous…
Yogi Yang
#1
Posté le 16 octobre 2017 - 14:31
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
Signaler
0
0
Paulo Oliveira
#2
Posté le 16 octobre 2017 - 15:00
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)
Signaler
0
0
Sascha77
#3
Posté le 16 octobre 2017 - 15:01
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
Signaler
0
0
Yogi Yang
#4
Posté le 17 octobre 2017 - 06:10
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,
Signaler
0
0
→ Revenir à WINDEV 2024
WINDEV 2024
WEBDEV 2024
WINDEV Mobile 2024
WINDEV (précédentes versions)
Français
English
Español
Portuguesa
Fermer cette fenêtre
Type de recherche
Uniquement les sujets
Tous les messages
Période de recherche
Date indifférente
Moins d'une heure
Moins de 24 heures
Moins d'une semaine
Moins d'un mois
Moins d'un an
Annuler
Aperçu de votre message
Ajouter une image
Importer une image depuis une URL
Envoyer une image depuis un fichier de votre disque
Déposez ici un fichier ou cliquez sur "Parcourir..."
ou
Annuler
0%
WLangage
SQL
XML, HTML
JAVA, Javascript
Texte