Questions tagged [postgresql-8.1]

Questions specific to version 8.1 of the widely-used PostgreSQL relational database system

This tag is for questions specific to version 8.1 of the widely-used .

Official documentation for this version: http://www.postgresql.org/docs/8.1/interactive/index.html

For general PostgreSQL questions, use the tag.

16 questions
14
votes
3 answers

How to use an ALIAS in a PostgreSQL ORDER BY clause?

I have the following query: SELECT title, (stock_one + stock_two) AS global_stock FROM product ORDER BY global_stock = 0, title; Running it in PostgreSQL 8.1.23 i get this error: Query failed: ERROR: column "global_stock" does…
Marcio Mazzucato
  • 8,841
  • 9
  • 64
  • 79
10
votes
3 answers

Select value from an enumerated list in PostgreSQL

I want to select from an enumaration that is not in database. E.g. SELECT id FROM my_table returns values like 1, 2, 3 I want to display 1 -> 'chocolate', 2 -> 'coconut', 3 -> 'pizza' etc. SELECT CASE works but is too complicated and hard to…
Turtle
  • 101
  • 1
  • 3
8
votes
2 answers

Get average value from the "last" N rows in a table

In my Postgres database table I can find the last 20 entries of cap_cs137 by date order: select cap_cs137 FROM capintec ORDER BY cap_date DESC LIMIT 20; I can also get the average: select avg(cap_cs137) FROM capintec LIMIT 20; However, how do I…
moadeep
  • 3,988
  • 10
  • 45
  • 72
5
votes
5 answers

SQL query to search an unique ID that can be in three different tables

I have three tables that control products, colors and sizes. Products can have or not colors and sizes. Colors can or not have sizes. product color size ------- ------- ------- id …
Marcio Mazzucato
  • 8,841
  • 9
  • 64
  • 79
3
votes
2 answers

Check for complete duplicate rows in a large table

My original question with all the relevant context can be found here: Adding a multi-column primary key to a table with 40 million records I have a table with 40 million rows and no primary key. Before I add the primary key, I would like to check if…
shaun
  • 560
  • 1
  • 11
  • 29
3
votes
1 answer

sql sliding window - finding max value over interval

i have a sliding window problem. specifically, i do not know where my window should start and where it should end. i do know the size of my interval/window. i need to find the start/end of the window that delivers the best (or worst, depending on…
jasonmclose
  • 1,667
  • 4
  • 22
  • 38
1
vote
2 answers

Get all top 5 id(an array) from a range of dates

I need to query the top 5 value from tableA. Such as below select id, count(occurrence), date from (select id, unnest(value) as occurrence, date from tableA) as a group by id, occurrence, date order by occurrence desc …
momokjaaaaa
  • 1,293
  • 3
  • 17
  • 32
1
vote
1 answer

Sanitize input to a column in postgres

So, I think this should be fairly simple, but the documentation makes it seem somewhat more complicated. I've written an SQL function in PostgreSQL (8.1, for now) which does some cleanup on some string input. For what it's worth, the string is an…
dannysauer
  • 3,793
  • 1
  • 23
  • 30
0
votes
0 answers

PostgreSQL INSERT syntax error command error

I don't know why error when Postgres SQL run this SQL command: INSERT INTO "mb_member_points" ("code","value","acc_value","cur_value","cur_acc_value") VALUES ('A001132451','-Qyq2\','kL0GSG',1,1); ERROR: syntax error at or near "kL0GSG" at…
Dang Thach Hai
  • 347
  • 3
  • 10
0
votes
0 answers

Re-use sql query result in stored procedure of postgreSQL

I am new to stored procedure in postgres. I know how to write my procedure but it will not work as I want. Let me explain my scenario what kind of output and what I want to achieve. I am using postgres 8.1 version. result = select u.name from users…
Kushal Jain
  • 3,029
  • 5
  • 31
  • 48
0
votes
1 answer

Migration from PostreSQL to MySQL using MySQL Workbench trows errors

I am trying to migrate a PostreSQL database to a local MySQL server using MySQL Workbench. I have set both connections, tested them and succeded, selected schemas to migrate and clicked next. However, it always ends up at Reverse engineer selected…
0
votes
1 answer

Error while creating table in postgres 8.1

My query: create table schema1.new_table (like schema2.some table); gives an error. Is this due to version 8.1? Is it possible to use two different schemas while creating table?
0
votes
1 answer

I am trying to do a massive PostgreSQL update and can not figure out the proper way

UPDATE member_copy SET locked_date = CURRENT_DATE, notes = ( SELECT notes FROM member_copy WHERE ID = 17579 ) || ' CLOSED' WHERE ID = 17579 I am trying to run a database update just like this in…
inimrepus
  • 69
  • 3
  • 8
0
votes
1 answer

Postgres 8.1 error message (data type)

Im using postgres version 8.1. I want to use string to array and unnest functions. 8.1 does not support unnest so I've created it using code found via Google and stackoverflow. My error message is as follows: ERROR: column "unnested" is of type…
nlstocks
  • 1
  • 1
0
votes
1 answer

Installing Postgresql 8.1.17 server on RHEL

I have a my production database on PostgreSQL 8.1.17 server. I want to migrate it from one Linux server to another. On another Linux server I am not able to install the PostgreSQL 8.1.17 server using rpm. I got the rpm file from…
1
2