如何将SQL结果存储为变量,并在PostgreSQL的后续SQL命令中使用它

时间:2015-12-01 18:27:11

标签: sql postgresql

我想赶上当月的第一天:

select date_trunc('month',  (CURRENT_DATE - INTERVAL '1 day')::date)

并打算在后续SQL命令中将其用作变量start_date,如:

select * from table where create_time > start_date;

如何在PostgreSQL中实现它?谢谢!

1 个答案:

答案 0 :(得分:0)

ifstream infile("material_properties.txt");
if (!infile)
{
    cout << "File material_properties.txt not found." << endl;
    return -1;
}

int lines = 0;
string line;
while (getline(infile, line))
{
    ++lines;
}

vector< vector<int> > properties(lines,vector<int>(3));

while (getline(infile,line)) {

    for(int i=0; i < lines; i++){
        for (int j=0; j<4; j++){
            infile  >> properties[i][j];
        }
    }

}