&&&&&&&&&&&&&&一个简单的SQL语句问题&&&&&&&&&&&& 早上结帐

LWWL 2004-03-15 09:08:54
我想加个单位这个字段但又不能按单位分组, 我是这样加的(肯定报错):
select a.id,b.供应商,b.名称,b.规格,b.单位
,数量=sum(b.数量*a.数量),总价=sum(b.数量*b.单价)
,合计=sum(a.数量*b.数量*b.单价)
into tmp
from tcg_idx a
join tcg b on a.id=b.idx
join tcg_main c on b.idmain=c.id
where b.idmain=1
group by a.id,b.供应商,b.名称,b.规格
怎么做?
如何把上面查询出的结果插入到1个TMP表中?
...全文
69 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
LWWL 2004-03-15
  • 打赏
  • 举报
回复
insert into tmp
select a.id as idx,b.供应商,b.名称,b.规格,单位=max(b.单位),b.单价
,数量=sum(b.数量*a.数量),总价=sum(b.数量*b.单价)
,合计=sum(a.数量*b.数量*b.单价)
from tcg_idx a
join tcg b on a.id=b.idx
join tcg_main c on b.idmain=c.id
where b.idmain=@h
group by a.id,b.供应商,b.名称,b.规格,b.单价
报错:仅当使用了列的列表,并且IDENTITY_INSERT为ON时,才能在表'tmp'中为标识列指定显示值
tmp 字段:
id(自增的,int) idx(int) 供应商 名称 规格 单价 单位 数量 总价
midnight2002 2004-03-15
  • 打赏
  • 举报
回复
select * into table_a from table_b 是从表a查询插入b表,适用于b表不存在,要生成b表的情况。
insert into table_b select * from table_a 适用于将a表查询到的数据插入b表。
realgz 2004-03-15
  • 打赏
  • 举报
回复
insert into tmp select …… from 吗
如果语句是动态生成的就
insert into tmp exec (@exec)
victorycyz 2004-03-15
  • 打赏
  • 举报
回复

插入数据用insert into table select ....的语法格式。

你能不能把你的问题重新完整地贴一下?
leeboyan 2004-03-15
  • 打赏
  • 举报
回复
insert into tmp +你的那一堆
LWWL 2004-03-15
  • 打赏
  • 举报
回复
我说错了 大哥
那个TMP是我建立的1个表 表里面都有字段 INTO的话肯定是先删除后建立,我不想这样而是直接插入怎做?
realgz 2004-03-15
  • 打赏
  • 举报
回复
或者是还有什么其他需求?
realgz 2004-03-15
  • 打赏
  • 举报
回复
select a.id,b.供应商,b.名称,b.规格,单位=max(b.单位)
,数量=sum(b.数量*a.数量),总价=sum(b.数量*b.单价)
,合计=sum(a.数量*b.数量*b.单价)
into tmp
from tcg_idx a
join tcg b on a.id=b.idx
join tcg_main c on b.idmain=c.id
where b.idmain=1
group by a.id,b.供应商,b.名称,b.规格
--有问题吗?
本帖最后由 hhmxxx 于 2012 7 18 20:51 编辑 惠普实验室曾经有一个Ocr引擎 支持中文的识别 这个库叫tesseract ocr 最新版本是3 01 库的源码在这里下载:http: code google com p tesseract ocr downloads list ExcelHome 网友把这个库封装成了一个进程外Com服务器 可以在Excel或者Word或者IE或者其他支持Com技术的程序中调用(32位或者64位的Excel Word都可以调用) 首先下载我的封装库 安装MyOcrServer v100 exe 安装完成后可以这样在Excel中使用 Dim FMyFuns As Object Dim MyStr As String Set FMyFuns CreateObject "MyOcrServer MyOcrServerCom" MyStr FMyFuns TsOcr "E: test jpg" "3" "3" "0" "chi sim" MsgBox MyStr Set FMyFuns Nothing 参数说明:第一个为文件名 第二个为引擎模式EngineMode emTesseractOnly emCubeOnly emCombined emDefault ;第一个为0 依此类推 第三个为PageSegmentation psOSDOnly psAutoOSD psAutoOnly psAuto psSingleColumn psSingleVerticalBlock psSingleBlock psSingleLine psSingleWord psCircleWord psSingleChar ; 第四个为PixelFormat piAuto pi8bit pi24bit pi32bit ; 第五个为识别使用的语言模块 比如英文"eng" 中文"chi sim" 有兴趣的可以去试试 ">本帖最后由 hhmxxx 于 2012 7 18 20:51 编辑 惠普实验室曾经有一个Ocr引擎 支持中文的识别 这个库叫tesseract ocr 最新版本是3 01 库的源码在这里下载:http: code google com p tesseract ocr downloads list ExcelHome 网友把这个库封装成了一个 [更多]
xml <!-- [xml] (xml / csv) 数据类型xml/csv--> ; <!-- 如果使用csv作为数据的话,需要使用这个属性;表示文件数据分隔符,(平常以";"和","为主) [;] (string) csv file data separator (you need it only if you are using csv file for your data) --> 1 <!-- 如果使用的是csv数据,可以设置跳过几行再显示数据,默认为0表示csv中的数据全部显示,大于n(n>0);表示前面n行都不显示[0] (Number) if you are using csv data type, you can set the number of rows which should be skipped here --> <!-- 设置系统中的字体[Arial] (font name) use device fonts, such as Arial, Times New Roman, Tahoma, Verdana... --> <!-- 设置所有文本的大小,默认为11,具体的文本的字体大小也可以在下面的设置中设置[11] (Number) text size of all texts. Every text size can be set individually in the settings below --> <!-- 同上[#000000] (hex color code) main text color. Every text color can be set individually in the settings below--> . <!-- 小数分隔符,默认为[,]注:该属性只是用来显示,而在csv数据文件中,必须使用[.] (string) decimal separator. Note, that this is for displaying data only. Decimals in data xml file must be separated with a dot --> <!-- 千位分隔符,默认为空[ ] (string) thousand separator. use "none" if you don't want to separate --> 3 <!-- 如果百分数格式的数字,后面的小数位小于该属性的值,则在小数后面加0补充。如54.2%,该属性设置为3,那么显示的效果为54.200%。[] (Number) if your value has less digits after decimal then is set here, zeroes will be added --> <!--设置科学记数法的最小值 [0.000001] If absolute value of your number is equal or less then scientific_min, this number will be form

22,298

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧