寻求一sql查询 - MS-SQL Server / 基础类
有几千行数据.
查询时候
select * from ssq where 编号 in('1','2','2','4')
如何使编号为2的出现两次
如果
select * from ssq where 编号 in('1','2','2','4','4','4')
使2出现2次,4 出现3次
编号 in 后面可以跟几百个编号的情况,谁有好的解决办法,谢谢了!!
你的数据时什么样的?
select * from ssq where 编号 =1
union all
select * from ssq where 编号 =2
union all
select * from ssq where 编号 =3
union al
select * from ssq where 编号 =4
数据表结构复杂和数据量特别大的时候建议用查询计划仔细份分析 比选一下各种方案
in里出现的重复是不起作用的
SQL code:
----------------------------------------------------------------------------------
-- Author : htl258(Tony)
-- Date : 2010-05-15 08:58:38
-- Version: Microsoft SQL Server 2008 (RTM) - 10.0.1600.22 (Intel X86)
-- Jul 9 2008 14:43:34
-- Copyright (c) 1988-2008 Microsoft Corporation
-- Developer Edition on Windows NT 5.1 <X86> (Build 2600: Service Pack 2)
-- Blog : http://blog.csdn.net/htl258
----------------------------------------------------------------------------------
--> 生成测试数据表: [TB]
IF OBJECT_ID('[TB]') IS NOT NULL
DROP TABLE [TB]
GO
CREATE TABLE [TB] ([Id] [int],[PId] [int])
INSERT INTO [TB]
SELECT '1','0' UNION ALL
SE
相关问答:
执行的顺序:
1)文件浏览框(选择文件使用)
选择好文件后
点击一个导入按钮的时候 ,把上面上传框里的csv文件以一个ID为文件名,上传到**/**文件夹下
2)读取这个文件夹下的csv的文件,转换成sql
3 ......
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jas ......
求个vb中的sql语句的写法,次sql语句的用法是分页程序
我写的如下:其中A是用来接收每页显示的记录的条数,B是用来接收显示的当前的页面.
sqltext="select top A * from log where id not in(select top ( ......
有TABLEA 字段为 采购单号、行号、物料编码、入库日期
现想按照物料编码查询最大入库日期
语句如下:
SELECT 采购单号、行号、物料编码、入库日期 from TABLEA A WHERE 入库日期=(SELECT MAX(入库日期 ......
原SQL语句SQL code:
SELECT t6.FName '操作工',t1.FDate '日期',t5.FName '制单人',t3.FName '设备',t4.FName '班制',
t7.FBillNo '工艺指令单号',t8.FName '岗位',t2. ......