我的MSN是[email protected]
希望有高手可以为我解答

解决方案 »

  1.   

    select Quotiety
    from tablename
    where PriceValueBegin>5.5
    and PriceValueEnd    <=5.5
      

  2.   

    上面错了,找出5.5的记录
    select Quotiety
    from tablename
    where PriceValueBegin<=5.5
    and PriceValueEnd    >5.5对新纪录的判断:
    if exists (
    select 1 from tablename where 
    (PriceValueBegin<=5 and 
    and PriceValueEnd    >5)
    or (PriceValueBegin<=7 and 
    and PriceValueEnd    >7)
      

  3.   

    对新纪录的判断:
    if exists (
    select 1 from tablename where 
    (PriceValueBegin<=5 and 
    and PriceValueEnd    >5)
    or (PriceValueBegin<=7 and 
    and PriceValueEnd    >7)
    )
     print '5-7有重复'
      

  4.   

    to lnhndx(凉风)
    就是给这个表添加加价率
    比如已经有
    5     7     1.2
    8     9     1.23
    11    15    1.55我添加6-10时,就要判断是否已经有相同那一段的值,6-10元这间,包括5-7中和8-9中的部分,所以添加就不能成功,我的意思是如何判断比较好不知道有没有是否做过这样的设计
      

  5.   

    TO Haiwer(海阔天空)
    你的方法有些仍然不能判断到所有的比如
    5    6
    6    8
    9    10理论上来说我应该能添加8-9,
    因为我的单价是满足>=PriceValueBegin,<PriceValueEnd的
      

  6.   

    对新纪录的判断:
    if exists (
    select 1 from tablename where 
    (PriceValueBegin<=8 and 
    and PriceValueEnd    >8)
    or (PriceValueBegin<=9 and 
    and PriceValueEnd    >9)
    ) print '8-9有重复'
      

  7.   

    你测试过没有?!对新纪录的判断:
    if exists (
    select 1 from tablename where 
    (PriceValueBegin<=8 and 
    and PriceValueEnd    >8)
    or (PriceValueBegin<=9 and 
    and PriceValueEnd    >9)
    ) print '8-9有重复'
      

  8.   

    必须先明确
    5    6
    的意思是(5,6]或者[5,6),不能是[5,6]或者(5,6)如果是[5,6)
    那8 9的判断是if exists (
    select 1 from tablename where 
    (PriceValueBegin<=8
    and PriceValueEnd    >8)
    or (PriceValueBegin<9 
    and PriceValueEnd    >9)
    ) print '8-9有重复'
    如果是(5,6]
    那8 9的判断是if exists (
    select 1 from tablename where 
    (PriceValueBegin<8
    and PriceValueEnd    >8)
    or (PriceValueBegin<=9 
    and PriceValueEnd    >9)
    ) print '8-9有重复'
      

  9.   

    PriceValueBegin是>=
    PriceValueEnd    是<PriceValueEnd
      

  10.   

    我这样改了
    @PriceValueBegin money,
    @PriceValueEnd money
    select 1 from PriceQuotiety where
     (PriceValueBegin<@PriceValueBegin and  PriceValueEnd >@PriceValueBegin) or (PriceValueBegin<@PriceValueEnd and PriceValueEnd  >@PriceValueEnd)
      

  11.   

    declare @num int
    set @num=(select count(*) from table_name
             where (@start between PriceValueBegin and PriceValueEnd)
             or (@end between PriceValueBegin and PriceValueEnd) )
    if @num=0 then
    begin
     print 'it can be Add!'
    end
      

  12.   

    不知道我这样写得对不对
    CREATE PROCEDURE PriceQuotiety_Exists
    @PriceValueBegin money,
    @PriceValueEnd money
    AS

    DECLARE @Err int  --是否存在--判断是否已经有这个起始价
    IF EXISTS(SELECT * FROM PriceQuotiety WHERE PriceValueBegin=@PriceValueBegin)
    BEGIN
    SET @Err = 0
    END
    ELSE
    BEGIN
    --判断结束值是否已经有了
    IF EXISTS(SELECT * FROM PriceQuotiety WHERE PriceValueEnd=@PriceValueEnd)
    BEGIN
    SET @Err = 0
    END
    ELSE
    BEGIN
    IF EXISTS(select 1 from PriceQuotiety where (PriceValueBegin<@PriceValueBegin and  PriceValueEnd >@PriceValueBegin) or (PriceValueBegin<@PriceValueEnd and PriceValueEnd  >@PriceValueEnd))
    BEGIN
    SET @Err = 0
    END
    ELSE
    SET @Err = 1
    END
    END
    RETURN @Err
    GO
      

  13.   

    我这样写了,不知道对不对
    CREATE PROCEDURE PriceQuotiety_Exists
    @PriceValueBegin money,
    @PriceValueEnd money
    AS

    DECLARE @Err int  --是否存在--判断是否已经有这个起始价
    IF EXISTS(SELECT * FROM PriceQuotiety WHERE PriceValueBegin=@PriceValueBegin)
    BEGIN
    SET @Err = 0
    END
    ELSE
    BEGIN
    --判断结束值是否已经有了
    IF EXISTS(SELECT * FROM PriceQuotiety WHERE PriceValueEnd=@PriceValueEnd)
    BEGIN
    SET @Err = 0
    END
    ELSE
    BEGIN
    IF EXISTS(select 1 from PriceQuotiety where (PriceValueBegin<@PriceValueBegin and  PriceValueEnd >@PriceValueBegin) or (PriceValueBegin<@PriceValueEnd and PriceValueEnd  >@PriceValueEnd))
    BEGIN
    SET @Err = 0
    END
    ELSE
    SET @Err = 1
    END
    END
    RETURN @Err
    GO
      

  14.   

    不能用between and,它是<= >=的意思
      

  15.   

    CREATE PROCEDURE PriceQuotiety_Exists
    @PriceValueBegin money,
    @PriceValueEnd money
    AS

    DECLARE @Err int  --是否存在--判断是否已经有这个起始价
    IF EXISTS(select 1 from PriceQuotiety where (PriceValueBegin<=@PriceValueBegin and  PriceValueEnd >@PriceValueBegin) or (PriceValueBegin<@PriceValueEnd and PriceValueEnd  >@PriceValueEnd))
    BEGIN
    SET @Err = 0
    END
    ELSE
    SET @Err = 1
    RETURN @Err
    GO