我正在尝试列出客户的姓氏和名字,以及帐户类型/说明,但仅列出每种帐户类型余额最低的名称。 以下是我到目前为止的情况:
Select Surname || ', ' || First_name AS "Name", account_description
from WGB_CUSTOMER join WGB_ACCOUNT using (Customer_number) join
WGB_ACCOUNT_TYPE using (Account_type)
where salary <ANY
(select MIN(Balance), account_type
from wgb_account
Group by account_type);
这是一个错误,并且说的值太多了。代码的最后一部分(从选择MIN(余额)开始,仅显示仅具有最低余额的帐户类型。
如果有人能提供帮助,我将非常感激。对不起,英语不是我的第一语言。
感谢。
答案 0 :(得分:0)
使用import System.IO
import Control.Applicative
import Data.Maybe
data Value = Str String
| Number Double
| Boo Bool
| Object [(String, Value)]
| Array [Value]
| Null deriving (Eq, Ord, Show)
class Deserial a where
deserialize :: Value -> Maybe a
data Person = Person String Double deriving (Show)
makePerson name age = case age of
Number n -> Just (Person name n)
_ -> Nothing
instance Deserial Person where
deserialize v = case v of
Object [(name, age)] -> makePerson name age
_ -> Nothing
getString (Str s) = s
getNumber (Number n) = Just n
getNumber _ = Nothing
main = do
let jason = Object[("TestName", Number 3)]
let _deserialized = _deserialize jason
--this next line does not compile
let deserialized = deserialize jason
rank() over (partition by
使用Select
Name,
account_description
from (
select Surname || ', ' || First_name AS Name
account_description
rank() over (partition by Account_type order by Balance) rnk
from WGB_CUSTOMER
) x
where rnk = 1;
join