使用CASE WHEN子句为某些行创建SQL Server视图列

时间:2019-07-01 15:41:07

标签: sql-server

我有以下SQL代码:

nom_acc = {"qeso":"qes", "os":"os", "sondra":"sondre", "mawizzi":"mawizze", "khewo":"khewe", "alegra":"alegre", "kendra":"kendre", "zhalia":"zhalie", "achrakh":"achrakh", "ador":"ador", "hoggi":"hogge", "soqwi":"soqwe"}

usedWords = []

def wordChoice():
    global usedWords
    print(usedWords) ### DELETE LATER

    word = random.choice(list(nom_acc))     ### randomly pick a key from a dictionary (which is the nominative form)
    print(word) ### DELETE LATER 
    if word in usedWords: 
        print("gotta pick another word") ### DELETE LATER
        return wordChoice() # return correct recursive result 
    else: 
        usedWords.append(word)          
        accusative = nom_acc[word]
        return word, accusative # This return statement should be inside the else statement for clearness

它会生成这样的网格视图:

enter image description here

我希望生成这样的内容:

enter image description here

基本上,我真正想要实现的是,当WHEN子句未满时,将ExpenseCategories的值设置为NULL,但具有相同ExpenseID的行组的ExpenseCategories应该设置为[Expense Category]。 / p>

任何指导将不胜感激。

谢谢

0 个答案:

没有答案