Oracle 根据条件in中值的顺序输出结果集

当我们用条件in查询数据时,我们希望输出的结果集是按照条件in里面的值的顺序展示的时,比如:

--有如下表:
SQL> select * from ordertest t;
ID    NAME
----- ----------------
a     甲
b     乙
c     丙
d     丁

--当我们 t.id in ('a','c','d','b') 时,我们希望输出的结果是按照 a、c、d、b排序的,但实际结果是:
SQL> select * from ordertest t where t.id in ('a','c','d','b');
ID    NAME
----- ----------------
a     甲
b     乙
c     丙
d     丁

--为此可以使用order by decode,达到我们目的,如下:
SQL> select * from ordertest t where t.id in ('a','c','d','b') order by decode(t.id,'a',1,'c',2,'d',3,'b',4);
ID    NAME
----- ----------------
a     甲
c     丙
d     丁
b     乙

2015年11月5日

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
您好!对于使用C语言进行中值滤波的输出结果,可以按照以下步骤进行操作: 1. 首先,根据您的需求,确定输入图像的大小和类型,并创建一个相应的图像数组。 ```c int width = 图像宽度; int height = 图像高度; unsigned char* inputImage = (unsigned char*)malloc(width * height * sizeof(unsigned char)); ``` 2. 将输入图像数据存储到inputImage数组中,可以通过文件读取或其他方式获取。 3. 创建一个与输入图像大小相同的输出图像数组。 ```c unsigned char* outputImage = (unsigned char*)malloc(width * height * sizeof(unsigned char)); ``` 4. 实现中值滤波算法,对输入图像进行处理。 ```c int filterSize = 滤波窗口大小; // 根据需求确定窗口大小 int halfSize = filterSize / 2; for (int y = halfSize; y < height - halfSize; y++) { for (int x = halfSize; x < width - halfSize; x++) { unsigned char window[filterSize * filterSize]; int k = 0; for (int j = -halfSize; j <= halfSize; j++) { for (int i = -halfSize; i <= halfSize; i++) { window[k++] = inputImage[(y + j) * width + (x + i)]; } } // 对窗口内的像素值排序 for (int i = 0; i < filterSize * filterSize - 1; i++) { for (int j = 0; j < filterSize * filterSize - i - 1; j++) { if (window[j] > window[j + 1]) { unsigned char temp = window[j]; window[j] = window[j + 1]; window[j + 1] = temp; } } } // 中值为排好序的像素值的中间值 outputImage[y * width + x] = window[filterSize * filterSize / 2]; } } ``` 5. 处理完成后,您可以将输出图像保存到文件或进行后续操作。 ```c // 将输出图像保存到文件 FILE* outputFile = fopen("outputImage.bmp", "wb"); fwrite(outputImage, sizeof(unsigned char), width * height, outputFile); fclose(outputFile); ``` 请注意,上述代码仅为简单示例,并未包括错误处理和内存释放等。实际使用时,还需进行适当的错误检查和资源管理。 希望能对您有所帮助!如有更多问题,请随时提问。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值