SQL Query Again - Complex

  • how many rows do you get by doing a "select * from tempBets where matches = '4' and

    mystery = '1'" ?!?!

    Also you may have previous inserts in your winners table - did you check ?!







    **ASCII stupid question, get a stupid ANSI !!!**

  • 2 Records only.

    I have other inserts too.

  • Thanks Sushila, I solved the prbs.

    I forgot to add a DRAWID = @DRAWID. Thats why the extra records

    Thank you so much..

  • as noel or remi would say - hth!







    **ASCII stupid question, get a stupid ANSI !!!**

  • is that another vote for sushila then 

    Far away is close at hand in the images of elsewhere.
    Anon.

  • oh puhleez - i wouldn't dare compete with the likes of you, noel, remi, jesper, ray m etc. for votes - you guys are superlative - i just try very hard!

    ps: forgot to add...it's probably because I ate those darn chalks instead of having them thrown at me...!!!!







    **ASCII stupid question, get a stupid ANSI !!!**

  • Don't forget modest as well 

    Far away is close at hand in the images of elsewhere.
    Anon.

  • Thanks to everyone whom have helped me..

  • My friend needs some help. He wants his query to display records after a certain date.

    @Date = '7/7/2005'

    SELECT * FROM USER WHERE DATE = AFTER @DATE

    Something like that, he was to display all records After this @Date. And another Query to display All records Before this particular @Date

    Thanks in advance

  • raj - why don't you start a new thread for this ?!

    is the column a datetime one ?!

    ask him to try "select * from user where date >= @date"...







    **ASCII stupid question, get a stupid ANSI !!!**

  • Guys another query...Im working on a Stored procedure.

    What I want to do, Im going to search my Winner Table, and calculate the Sum of the Winnings for Each User and Insert it into another Table.

    INSERT INTO WINNER(USERID,AMOUNT)

    SELECT USERID, SUM(AMOUNT) FROM TEMP_WINNER WHERE USERID = @USERID.

    But the problem is, I need to specify each User's USERID. Which i do not want, I want SQL to automatically get the USERIDs and compute the Total Amount and Save it in another table.

  • Raj - again not sure I understand why you want to keep the winnings separate - at any rate, you can get the total winnings per user by grouping...like so...

    SELECT USERID, SUM(AMOUNT) AS TotalWinnings FROM TEMP_WINNER

    GROUP BY USERID







    **ASCII stupid question, get a stupid ANSI !!!**

  • Oh, i didnt realise, that we can group by UserID

  • IF Statement in SQL.

    Im doing something like this in SQL.

    SET @Share = @Share1 + @Share2

    IF NOT (@Share = 0) THEN

    @Amount = @Pool / @Share

    ELSE

    @Share = 0

    END

    Is my query correct in sql? Im trying to get this work, in my Stored Procedure but its not working..

  • declare @Share int

    declare @Share1 int

    declare @Share2 int

    declare @Pool int

    declare @Amount int

    SET @Share = @Share1 + @Share2

    IF (@Share > 0)

    SET @Amount = @Pool / @Share

    ELSE

    SET @Share = 0 ...don't really need the "else" condition since @Pool/@Share is done only when > 0







    **ASCII stupid question, get a stupid ANSI !!!**

Viewing 15 posts - 61 through 75 (of 79 total)

You must be logged in to reply to this topic. Login to reply