我的MySQL查询有问题,我正在使用这个案例给它一个排序顺序.订单取决于序列号.
我的查询是:
SELECT DISTINCT id, price, itemnr, itemnr_ori, link, name, setinfo
CASE WHEN itemnr_ori LIKE '%-%-s%' THEN 0 WHEN itemnr_ori LIKE 'z-%-%' THEN 1
WHEN itemnr_ori LIKE 'ak-%' THEN 2
WHEN itemnr_ori LIKE 'fdc-%' THEN 3
WHEN itemnr_ori LIKE 'max-%' THEN 4
ELSE 5 END
AS sort_order FROM items2 WHERE category1 = 'Overige' AND category2 = 'Afrikaanse Overige' ORDER BY sort_order ASC, price ASC, itemnr_ori ASC
Run Code Online (Sandbox Code Playgroud)
我收到这个错误:
#1064 - You have an error in your SQL syntax; check the manual …
Run Code Online (Sandbox Code Playgroud) 我试图编写一个程序来帮助我找到给定角度的三角函数值。下面是程序,
#include<iostream>
#include<cmath>
using namespace std;
void convert(char type);
int main()
{
char ch;
cout<<"Enter what angle value u want to calculate: 'c' for cos, 's' for sine and 't' for tan: ",cin>>ch;
convert(ch);
return 0;
}
void convert(char type)
{
float angle;
double num;
switch (type)
{
case 'C' || 'c':
cout<<"Enter angle value to calculate cos equivalent: ",cin>>angle;
num = cos(angle);
break;
case 's' || 'S':
cout<<"Enter angle value to calculate sin equivalent: ",cin>>angle;
num = sin(angle);
break; …
Run Code Online (Sandbox Code Playgroud) 我想在我的代码中创建一个switch语句,其代码遍及大范围的整数(1-15000),分为3个部分:1-5000,5001-10000,10001-15000.
我试过这样一次:
switch(number) {
case 1 ... 1000: (statement here);
Run Code Online (Sandbox Code Playgroud)
这给了我一个关于"......"的语法错误 - "预期的a:".
然后我尝试了:
switch (number) {
case 1:
case 5000:
(statement);
break;
Run Code Online (Sandbox Code Playgroud)
这个方法确实编译但是没有按预期工作,对于没有明确列出的案例的错误答案.
在网上找不到任何其他建议.有人可以帮忙吗?
我的表有以下列:
|blo|NotionalCurrency|Notional|Premiumcurrency|Basecurrency|Termcurrency|StructureName|Basemarketprice|Termmarketpriceprecent |Termmarketprice|
Run Code Online (Sandbox Code Playgroud)
我想从这些获得blo,货币和价格.下面是我的SQL:
select blo.opt,
case
when opt.premiumcurrency is not null and opt.structurename is not null then currency = opt.premiumcurrency
case
when opt.notionalcurrency = opt.basecurrency and opt.premiumcurrency = opt.termcurrency then price = opt.termmarketpricepercent / opt.notional
else
case
when opt.premiumcurrency = opt.basecurrency then price = opt.basemarketprice /100
else
price = opt.termmarketpriceprecent /100
end
end
when price = 0 then price = 0.000001
end
FROM interface opt
WHERE opt.notionalcurrency = opt.basecurrency and opt.premiumcurrency = opt.termcurrency;
Run Code Online (Sandbox Code Playgroud)
但我得到错误: ORA-00905: missing keyword
基本上,下面的逻辑应该用于获取/派生SQL以获得三列:Blo,货币和价格:
If …
Run Code Online (Sandbox Code Playgroud) 我们有4个地区: a
b
c
d
我们想把数字放在这些地区.
如何仅使用switch语句执行此操作:
the number divisible by 10 and divisible by 7 ?n region a
the number divisible by 10 but not divisible by 7 ?n region b
the number not divisible by 10 but divisible by 7 ?n region c
the number not divisible by 10 and divisible by 7 ?n region d
Run Code Online (Sandbox Code Playgroud)
例如,如果:
input 770 out put is a
input 200 output b
input 154 output c
Run Code Online (Sandbox Code Playgroud) 是否可以在开关盒环路中放置一个功能?因为我试过这个只是为了探索更多这个循环.虽然我尝试了其他方法,但我仍然存在问题.谁能帮我?
#include <stdio.h>
int main(void)
{
int choice;
switch(choice);
{
case 1:
{
int GetData()
{
int num;
printf("Enter the amount of change: ");
scanf("%d%*c", &num);
return (num);
}
int getChange (int change,int fifty,int twenty,int ten,int five)
{
int num = change;
fifty = num/50;
num %= 50;
twenty = num/20;
num %= 20;
ten = num/10;
num %= 10;
five = num/5;
num %= 5;
return (fifty, twenty, ten, five);
}
int main()
{
int change, fifty, twenty, ten, …
Run Code Online (Sandbox Code Playgroud) case ×7
c ×3
sql ×3
c++ ×1
date ×1
duplicates ×1
function ×1
int ×1
loops ×1
mysql ×1
oracle ×1
sql-like ×1
sql-order-by ×1
sql-server ×1