如果表为空,如何获取GBQ中的表计数列表

时间:2017-07-17 21:58:55

标签: google-bigquery

我有这个SQL语句,为SELECT _TABLE_SUFFIX AS table, nullif(count(*),0) as count FROM `mydataset.*` where _TABLE_SUFFIX in ( "TABLEA" , "TABLEB" , "TABLEC" ) group by _TABLE_SUFFIX order by _TABLE_SUFFIX 子句中的所有表提供行计数:

TABLEB

TableB为NULL。我知道这种情况。但输出会忽略TABLE, COUNT TABLEA, 315 TABLEC, 123 ,因为它被认为是空的。

我得到的回应是:

TABLE, COUNT
TABLEA, 315
TABLEB, 0
TABLEC, 123

我需要:

from tkinter import *
from random import randint
balance = (randint(100, 500))


class GUI:
    def __init__(self, master):
        frame = Frame(master)
        frame.pack()

        toolbar = Frame(root)
        toolbar.pack(side=TOP, fill=X)

        button1 = Button(toolbar, text="Deposit", width = 13, command=self.printBalance)
        button2 = Button(toolbar, text="Withdraw",width = 13, command=self.printBalance)

        button1.pack(side=LEFT)
        button2.pack(side=RIGHT)


        subMenu = Menu(menu)
        menu.add_cascade(label="Type of Account", menu=subMenu)
        subMenu.add_command(label="Standard", command= self.printBalance)
        subMenu.add_command(label="Interest", command= self.printBalance)

        text = Entry(root)
        text.pack()

        w = Label(root, text="Current Balance:")
        w.pack()

        w = Label(root, text=balance)
        w.pack()


    def printBalance(self):
            a = text.get()
            print(a)



class BankAccount(object):
    def __init__(self, initial_balance=0):
        self.balance = initial_balance
    def deposit(self, amount):
        self.balance += amount
    def withdraw(self, amount):
        self.balance -= amount       
    def get_balance(self, initial_balance, rate):
        return self.get_balance() * self._rate











root = Tk()
menu = Menu(root)
root.config(menu=menu)
root.title("Bank Account")
root.minsize(width=250, height=100)
root.maxsize(width=300, height=150)
GUI(root)

root.mainloop()

任何智慧都会受到高度赞赏。 感谢。

1 个答案:

答案 0 :(得分:2)

  

SQL语句,为in子句中的所有表提供行计数

尝试以下 - 适用于BigQuery Standard SQL

package items;

import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;

public class MyItems implements List<MyItem> {
    @Override
    public int size() {
        return 0;
    }

    @Override
    public boolean isEmpty() {
        return false;
    }

    @Override
    public boolean contains(Object o) {
        return false;
    }

    @Override
    public Iterator<MyItem> iterator() {
        return null;
    }

    @Override
    public Object[] toArray() {
        return new Object[0];
    }

    @Override
    public <T> T[] toArray(T[] a) {
        return null;
    }

    @Override
    public boolean add(MyItem generatePreSignedUrl) {
        return false;
    }

    @Override
    public boolean remove(Object o) {
        return false;
    }

    @Override
    public boolean containsAll(Collection<?> c) {
        return false;
    }

    @Override
    public boolean addAll(Collection<? extends MyItem> c) {
        return false;
    }

    @Override
    public boolean addAll(int index, Collection<? extends MyItem> c) {
        return false;
    }

    @Override
    public boolean removeAll(Collection<?> c) {
        return false;
    }

    @Override
    public boolean retainAll(Collection<?> c) {
        return false;
    }

    @Override
    public void clear() {

    }

    @Override
    public MyItem get(int index) {
        return null;
    }

    @Override
    public MyItem set(int index, MyItem element) {
        return null;
    }

    @Override
    public void add(int index, MyItem element) {

    }

    @Override
    public MyItem remove(int index) {
        return null;
    }

    @Override
    public int indexOf(Object o) {
        return 0;
    }

    @Override
    public int lastIndexOf(Object o) {
        return 0;
    }

    @Override
    public ListIterator<MyItem> listIterator() {
        return null;
    }

    @Override
    public ListIterator<MyItem> listIterator(int index) {
        return null;
    }

    @Override
    public List<MyItem> subList(int fromIndex, int toIndex) {
        return null;
    }
}