如何将一条记录分成两条记录呢,在线等待,急!!

handyworkroom 2003-08-30 07:50:59
在下面的一条记录
store表
storedate dining cent1 room cent2
2003-8-29 233.70 2 680.00 3

如何用SQL写,将记录分成两条记录
storedate item money cent
2003-8-29 dining 233.70 2
2003-8-29 room 680.00 3
...全文
49 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
lyguo 2003-08-30
  • 打赏
  • 举报
回复
select storedate,item='dining',ding,cent=cent1 from store
union all
select storedate,item='room',ding,cent=cent2 from store
order by storedate


楼上说的不错
zjcxc 元老 2003-08-30
  • 打赏
  • 举报
回复
你可以加个排序语句就行了嘛:

select storedate,item='dining',ding,cent=cent1 from store
union all
select storedate,item='room',ding,cent=cent2 from store
order by storedate
handyworkroom 2003-08-30
  • 打赏
  • 举报
回复
这样写的话,数据就不是按时间排的了,我想让它们有联系的(时间相同的)显示在一前一后,
pinghell 2003-08-30
  • 打赏
  • 举报
回复
这样可以呀
handyworkroom 2003-08-30
  • 打赏
  • 举报
回复
还有别的写法吗?
zjcxc 元老 2003-08-30
  • 打赏
  • 举报
回复
select storedate,item='dining',ding,cent=cent1 from store
union all
select storedate,item='room',ding,cent=cent2 from store

34,575

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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