SubQuery Question
От | Van Ingen, Lane |
---|---|
Тема | SubQuery Question |
Дата | |
Msg-id | A3FF4275060B76459B5C08A64AE330C805C3F9@twmail.esncc.com обсуждение исходный текст |
Список | pgsql-novice |
I am trying to make a query and subquery work, but no luck with the query. In the sample query below, I want to get a count of the number of different car models that have been sold during a specified period of time. The subquery below works fine. Since I am using this in a stored procedure, I want to select the count of values returned by the subquery below ainto a variable and work more with it. How do I put a count wrapper around the subquery enclosed in parenthesis below ? select into <count-variable> count(*) .. where ... (select distinct auto_model from car_lot where date_sold between '2005-01-01 00:00:00' and '2005-01-31 23:59:59') ; It seems like I should be able to do this is with one SQL statement. I considered inserting the sub-query answer into a temp table, then counting the records in the temp table, but don't want to incur the I/O. If I could stuff it into an array, then count the array, that would work also, but not sure how to do that. Does anyone have any thoughts?
В списке pgsql-novice по дате отправления: