Our server costs ~$56 per month to run. Please consider donating or becoming a Patron to help keep the site running. Help us gain new members by following us on Twitter and liking our page on Facebook!
Current time: December 22, 2024, 10:09 am

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A question about databases
#1
A question about databases
In 2018, on a test about databases (which I have failed multiple times) at my university, they had this task:
Quote:Napisati T-SQL funkciju koja prima 3 realna broja, te kao rezultat vraća onaj broj koji ima najveću apsolutnu vrijednost. Ako slučajno istu najveću apsolutnu vrijednost imaju dva ili tri broja potrebno je vratiti zbroj tih brojeva.
That is:
Quote:Write a T-SQL function that accepts 3 real numbers, and as a result it returns the number that has the biggest absolute value. If accidentally the same biggest absolute value is had by two or three numbers it is necessary to return the sum of those numbers.
How would you solve that?
Here is my attempt, I do not know if it is correct nor how to actually test it on my computer:
Code:
CREATE FUNCTION max_abs3(@x, @y, @z DECIMAL) RETURNS DECIMAL
BEGIN
    IF ABS(@x)=ABS(@y) AND ABS(@y)=ABS(@z)
    BEGIN
        RETURN @x+@y+@z;
    END;
    IF ABS(@x)=ABS(@y) AND ABS(@x)>ABS(@z)
    BEGIN
        RETURN @x+@y;
    END;
    IF ABS(@x)=ABS(@z) AND ABS(@x)>ABS(@y)
    BEGIN
        RETURN @x+@z;
    END;
    IF ABS(@y)=ABS(@z) AND ABS(@y)>ABS(@x)
    BEGIN
        RETURN @y+@z;
    END;
    IF ABS(@x)>ABS(@y) AND ABS(@x)>ABS(@z)
    BEGIN
        RETURN @x;
    END;
    IF ABS(@y)>ABS(@z) AND ABS(@y)>ABS(@x)
        RETURN @y;
    END;
    RETURN @z;
END;
I have only managed to install SQLite on my computer, and it apparently does not support custom SQL functions.
Reply
#2
RE: A question about databases
I have asked this question on a forum about SQL Server: https://www.reddit.com/r/SQLServer/comme...ium=mweb3x
Reply
#3
RE: A question about databases
Check with a linguist.

Boru
‘I can’t be having with this.’ - Esmeralda Weatherwax
Reply
#4
RE: A question about databases
My consulting rate is $50/hr, prepaid with a 3-hr minimum. All sales are final. No refunds.
Reply
#5
RE: A question about databases
(May 26, 2022 at 9:49 am)FlatAssembler Wrote: I have asked this question on a forum about SQL Server: https://www.reddit.com/r/SQLServer/comme...ium=mweb3x

Thank you for that update.

Keep us posted.
[Image: MmQV79M.png]  
                                      
Reply
#6
RE: A question about databases
The answer is moops. Coffee
[Image: extraordinarywoo-sig.jpg]
Reply
#7
RE: A question about databases
(May 26, 2022 at 12:30 pm)BrianSoddingBoru4 Wrote: Check with a linguist.

Boru

*snort*
Nay_Sayer: “Nothing is impossible if you dream big enough, or in this case, nothing is impossible if you use a barrel of KY Jelly and a miniature horse.”

Wiser words were never spoken. 
Reply
#8
RE: A question about databases
If you re-write the equation in Sumerian cuneiform (NOT Babylonian cuneiform as most do), then put it through a Hebrew translator into Greek (Macedonian, of course), then run it through Auto-Correct, you'll get it right.*






*or possibly wrong. 50/50 chance.

Playing Cluedo with my mum while I was at Uni:

"You did WHAT?  With WHO?  WHERE???"
Reply
#9
RE: A question about databases
(May 26, 2022 at 12:30 pm)BrianSoddingBoru4 Wrote: Check with a linguist.

Boru

I do not understand. What does this have to do with linguistics?
Reply
#10
RE: A question about databases
(May 27, 2022 at 6:26 am)FlatAssembler Wrote:
(May 26, 2022 at 12:30 pm)BrianSoddingBoru4 Wrote: Check with a linguist.

Boru

I do not understand. What does this have to do with linguistics?

Well, you submitted a linguistics idea to a mathematician, didn’t you?

Boru
‘I can’t be having with this.’ - Esmeralda Weatherwax
Reply





Users browsing this thread: 1 Guest(s)