如下sql语句,如何实现and后面的条件判断
select a.task_id,a.title,a.grade,a.school,
case when a.school=1 then 2 else cast((a.count1*100/c.count2) as dec(18,2)) end '比值——三个月登录过的用户'
from
(select b.id as task_id,b.title as title,b.grade as grade, ......
表A
id name
1 a
2 b
3 c
4 d
表B
id AID &nb ......
你们好,大侠们!
小弟在这跪求SQL语句,请大侠们帮忙。谢谢
现在有二个表,表虽然不同,但里面有些列是一样的。
我想吧表2的数据INSERT到表1里,条件是客户号相同则抛弃
列如一下代码(代码是我吓写的)
SQL code:
INSERT INTO TABLE1(
序号
,名字
,年龄
,客户号
)SELECT
SELECT Is ......
我想把表A变成表B,就是把字段3 根据字段1求平均数 怎么写SQL语句啊
求高手帮忙
-------------------------------
表A
字段1 字段2 字段3
A A1 150
A A2 150
A A3 150
B & ......
call表字段:
id time cost period
time 是打电话的开始时间,日期格式精确到豪秒,cost 是打电话的费用,
period 是打电话的时长,单位是秒;
现在要对这个表按日进行统计,即统计表sta中time 字段是精确到天, cost是一天内的电话的费用,period字段是6秒一个间隔段数量的总合
sta ......
import java.sql.Date;
import java.text.SimpleDateFormat;
public class text {
public static void main(String[] args) {
// TODO Auto-generated method stub
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
String dateString = ......