需要帮助编写代码 [英] Need help writing code

查看:97
本文介绍了需要帮助编写代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果有帮助的话.我需要每次选择公司时都需要检查的代码,在引荐"列中添加1

因此,如果选择公司abc inc作为人工,请插入数字1
如果推荐人<如果选择公司abc inc作为电气公司1加1 = 2,依此类推.

数据库表公司
列:
coID
CompanyName nvarchar
地址nvarchar
城市nvarchar
状态nvarchar
邮编数字
服务nvarchar
推荐数字

If any can help. I need code that check every time a company has being chosen for something the Referral column to add 1

so if company abc inc is chosen for labor insert the number 1
if company abc inc is chosen for electrical if referral is < 1 add 1 = 2 and so on.

Database Table Company
Columns:
coID
CompanyName nvarchar
Address nvarchar
City nvarchar
State nvarchar
Zip numeric
Services nvarchar
Referral numeric

推荐答案

与此有很多矛盾的地方.

您的公司表中包含事件信息,应将其删除到另一个对公司表有FK的表中.

服务表
ServiceID
公司编号
服务
日期等...

如果您无法更改数据结构,请查看row_number,运行总计和分区,假设sql 2005或更高版本
There are a number of things that are wrong with this.

Your company table has event information in it, this should be removed to another table with a FK to the Company table.

ServicesTable
ServiceID
CompanyID
Service
Date Etc...

If you cannot change your data structure then look into row_number, running totals and partition, this assumes sql 2005 or greater


这篇关于需要帮助编写代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆