Author Topic: Henious SQL Queries  (Read 1159 times)

0 Members and 1 Guest are viewing this topic.

Offline Kazan

  • PCS2 Wizard
  • 212
  • Soul lives in the Mountains
    • http://alliance.sourceforge.net
SELECT * FROM cmppeople WHERE Pos_Type='Scientists' ORDER BY Pos_Type,Pos_SubType,OrderOverride,SUBSTRING(Name, 1+Length(Name)-Locate(' ', REVERSE(Name))), SUBSTRING(Name, 1, Length(Name)-Locate(' ', REVERSE(Name)))
« Last Edit: March 02, 2004, 11:27:14 am by 30 »
PCS2 2.0.3 | POF CS2 wiki page | Important PCS2 Threads | PCS2 Mantis

"The Mountains are calling, and I must go" - John Muir

 

Offline 01010

  • 26
I don't get it, this isn't like one of CP's math jokes is it?
What frequency are you getting? Is it noise or sweet sweet music? - Refused - Liberation Frequency.

 

Offline aldo_14

  • Gunnery Control
  • 213
Quote
Originally posted by 01010
I don't get it, this isn't like one of CP's math jokes is it?


Database query.  I'd try to decipher it, but that colouring is giving me a headache :) *

* I know, I know - it's to clairfy the bracketing.  But i never liked SQL: anyways

 

Offline HotSnoJ

  • Knossos Online!
  • 29
    • http://josherickson.org
Probably has something to do with recent political/religious topics. :doubt:
I have big plans, now if only I could see them through.

LiberCapacitas duo quiasemper
------------------------------
Nav buoy - They mark things

 

Offline Kazan

  • PCS2 Wizard
  • 212
  • Soul lives in the Mountains
    • http://alliance.sourceforge.net
HotSnoj: that comment was extremely presumptious and outright false

STFU ESAD
PCS2 2.0.3 | POF CS2 wiki page | Important PCS2 Threads | PCS2 Mantis

"The Mountains are calling, and I must go" - John Muir

 

Offline Liberator

  • Poe's Law In Action
  • 210
Kazan == :mad: :mad: :mad: :mad: :mad:  most of the time
So as through a glass, and darkly
The age long strife I see
Where I fought in many guises,
Many names, but always me.

There are only 10 types of people in the world , those that understand binary and those that don't.

 

Offline HotSnoJ

  • Knossos Online!
  • 29
    • http://josherickson.org
Quote
Originally posted by Kazan
HotSnoj: that comment was extremely presumptious and outright false

STFU ESAD
:wtf: am I suppose to think?
SELECT * FROM cmppeople WHERE Pos_Type='Scientists'

Also:
Quote
Probably has something to do with recent political/religious topics. :doubt:
I have big plans, now if only I could see them through.

LiberCapacitas duo quiasemper
------------------------------
Nav buoy - They mark things

 

Offline Kazan

  • PCS2 Wizard
  • 212
  • Soul lives in the Mountains
    • http://alliance.sourceforge.net
HotSnoj: i work for DoE Ames Lab

you're suppose to think it has to do with my work - because IT DOES
PCS2 2.0.3 | POF CS2 wiki page | Important PCS2 Threads | PCS2 Mantis

"The Mountains are calling, and I must go" - John Muir

 

Offline aldo_14

  • Gunnery Control
  • 213
Quote
Originally posted by Kazan
SELECT * FROM cmppeople
WHERE Pos_Type='Scientists'
ORDER BY Pos_Type,Pos_SubType,OrderOverride,
SUBSTRING(Name, 1+Length(Name)-Locate(' ', REVERSE(Name))), SUBSTRING(Name, 1, Length(Name)-Locate(' ', REVERSE(Name)))


Well, it's been about 11/2 years since I last looked at SQL, so allow me some leeway here.........especially as this is off the top of my head

SELECT * - show all record fields in the selected tuples
WHERE Pos_Type='Scientists' - I presume pos-type is a field name?
ORDER BY Pos_Type,Pos_SubType,OrderOverride,
SUBSTRING(Name, 1+Length(Name)-Locate(' ', REVERSE(Name))), SUBSTRING(Name, 1, Length(Name)-Locate(' ', REVERSE(Name)))

- ORDER BY - in terms of priority, I think it's left-right (high-low) - Poa_type field, Pos_SubType field, OrderOverride field,

- now this next bit is a little hazy in particular, due to my unfamiliarity with the inbuild funcitons -

 SUBSTRING(Name, 1+Length(Name)-Locate(' ', REVERSE(Name))),
- the substring of the name field, taken from the last(?) whitespace

SUBSTRING(Name, 1, Length(Name)-Locate(' ', REVERSE(Name)))
- the substring of the name field, taken from the first(?) whitespace


So -
select and show all records
where pos_type (the field) is "Scientist"
order (the selected records) by Pos_type, Pos_SubType, OrderOverried, position of the last whitespace, position of the first whitespace (in order of priority)

Correct me it I'm wrong, it's nice to try and refresh these things from time to time.

EDIT: waittamo - this is (as a last resort)sorting by the length of the second or first name?
« Last Edit: March 02, 2004, 03:54:43 pm by 181 »

 

Offline HotSnoJ

  • Knossos Online!
  • 29
    • http://josherickson.org
Quote
Originally posted by Kazan
HotSnoj: i work for DoE Ames Lab

you're suppose to think it has to do with my work - because IT DOES
Quote
not that i speak from any form of experience, i'm 16.
I have big plans, now if only I could see them through.

LiberCapacitas duo quiasemper
------------------------------
Nav buoy - They mark things

 

Offline Kazan

  • PCS2 Wizard
  • 212
  • Soul lives in the Mountains
    • http://alliance.sourceforge.net
HotSnoj: i didn't say im 16 - are you quoting yourelf there

I am 20
PCS2 2.0.3 | POF CS2 wiki page | Important PCS2 Threads | PCS2 Mantis

"The Mountains are calling, and I must go" - John Muir

 

Offline mikhael

  • Back to skool
  • 211
  • Fnord!
    • http://www.google.com/search?q=404error.com
That was his point, Kaz. He's quoting him self by way of explaining why he didnt grok.
[I am not really here. This post is entirely a figment of your imagination.]

 

Offline Kazan

  • PCS2 Wizard
  • 212
  • Soul lives in the Mountains
    • http://alliance.sourceforge.net
i knew SQL when i was 16, i knew C++ when i was 14....
PCS2 2.0.3 | POF CS2 wiki page | Important PCS2 Threads | PCS2 Mantis

"The Mountains are calling, and I must go" - John Muir

 

Offline mikhael

  • Back to skool
  • 211
  • Fnord!
    • http://www.google.com/search?q=404error.com
HotSnoj==Kazan returns false, thus you cannot draw a direct parallel between HotSnoj and Kazan.
[I am not really here. This post is entirely a figment of your imagination.]

 

Offline Kazan

  • PCS2 Wizard
  • 212
  • Soul lives in the Mountains
    • http://alliance.sourceforge.net
althought i can say that his unspoken propsition of "if (age == 16) sql_knowledge = NONE" is invalid
PCS2 2.0.3 | POF CS2 wiki page | Important PCS2 Threads | PCS2 Mantis

"The Mountains are calling, and I must go" - John Muir

 

Offline aldo_14

  • Gunnery Control
  • 213
knows(x, SQL) ^ age(x,16)

{x/"Kazan"}

=> unifiable / satisfiable


alternately,

~knows(x, SQL) ^ age(x,16)

{x/"hotsnoj"}

=> unifiable / satisfiable
« Last Edit: March 02, 2004, 09:32:03 pm by 181 »

 

Offline mikhael

  • Back to skool
  • 211
  • Fnord!
    • http://www.google.com/search?q=404error.com
Absolutely, Kazan, however, when one adds the all important quantifier "person == 'hotsnoj'" we get the proper test:

if ((age == 16) && (person == 'hotsnoj') sql_knowledge = NONE

That is valid.
[I am not really here. This post is entirely a figment of your imagination.]

 

Offline Kazan

  • PCS2 Wizard
  • 212
  • Soul lives in the Mountains
    • http://alliance.sourceforge.net
mikhael - it is correct WITH The additional quantifier -- however just saying the origional is invalid - and that is what hotsnoj implied
PCS2 2.0.3 | POF CS2 wiki page | Important PCS2 Threads | PCS2 Mantis

"The Mountains are calling, and I must go" - John Muir

 

Offline Knight Templar

  • Stealth
  • 212
  • I'm a magic man, I've got magic hands.
To take a note from DG: This thread == :no: :no:
Copyright ©1976, 2003, KT Enterprises. All rights reserved

"I don't want to get laid right now. I want to get drunk."- Mars

Too Long, Didn't Read

 

Offline mikhael

  • Back to skool
  • 211
  • Fnord!
    • http://www.google.com/search?q=404error.com
Quote
Originally posted by Kazan
mikhael - it is correct WITH The additional quantifier -- however just saying the origional is invalid - and that is what hotsnoj implied


When he said "I'm only 16", he specified himself (hence the "I'm", thus the quantifier was both necessary and implicit, thus the original is valid.
[I am not really here. This post is entirely a figment of your imagination.]