Subject: | |
From: | |
Reply To: | |
Date: | Wed, 5 Sep 2007 10:34:23 -0400 |
Content-Type: | text/plain |
Parts/Attachments: |
|
|
So Basically, If I just pasted the following SQL query (up to the DROP
TABLE oscount;) it will just print out that list?
I'm being asked to product a list like below. I'm just not an SQL guy.
Mike
-----Original Message-----
[root@smmanager ~]# psql -h 127.0.0.1 -U postgres controlsmartdb
Welcome to psql 8.1.8, the PostgreSQL interactive terminal.
Type: \copyright for distribution terms
\h for help with SQL commands
\? for help with psql commands
\g or terminate with semicolon to execute query
\q to quit
controlsmartdb=# CREATE TEMPORARY TABLE oscount (mac CHARACTER
VARYING(64), os CHARACTER VARYING(64)); INSERT INTO oscount SELECT
DISTINCT user_mac,os_name FROM user_info WHERE login_time > (SELECT
EXTRACT(epoch from current_timestamp) * 1000 - (60 * 60 * 24 * 30 * 2));
INSERT INTO oscount SELECT DISTINCT dm_mac,dm_os FROM dm_report WHERE
current_timestamp - report_time < INTERVAL '2 months' AND dm_mac NOT IN
(SELECT mac FROM oscount); INSERT INTO oscount SELECT DISTINCT
mac,os_name FROM oob_user_info WHERE current_timestamp - login_time <
INTERVAL '2 months' AND mac NOT IN (SELECT mac FROM oscount); SELECT
os,count(*) FROM oscount GROUP BY os ORDER BY os; DROP TABLE oscount;
CREATE TABLE
INSERT 0 52
INSERT 0 1385
INSERT 0 31
os | count
----------------------------+-------
LINUX | 3
MAC_OSX | 56
WINDOWS_2K | 3
WINDOWS_95 | 1
WINDOWS_MCE_XP | 96
WINDOWS_PRO_XP | 1039
WINDOWS_TPC_XP | 13
WINDOWS_VISTA_BUSINESS | 14
WINDOWS_VISTA_ENTERPRISE | 2
WINDOWS_VISTA_HOME_BASIC | 38
WINDOWS_VISTA_HOME_PREMIUM | 119
WINDOWS_VISTA_ULTIMATE | 85
(12 rows)
DROP TABLE
controlsmartdb=#
|
|
|