Access-o-Mania

Access-Forum (Deutsch/German) => Tabelle/Abfrage => Thema gestartet von: Mak am September 27, 2010, 18:22:18

Titel: Gruppierung und Sperren von Datensätzen einer Tabelle über SQL Code
Beitrag von: Mak am September 27, 2010, 18:22:18
Hallo zusammen,

Ich besuche gerade einen Basis Course in Database ohne grüble über folgende Aufgaben:

Create a list of stuff (showing only staff IDs in alphabetical order) who manage property with the properties they manage (showing only property IDs and addresses).

Mein Code:
SELECT Distinct Staff.staffNo, PropertyForRent.propertyNo, PropertyForRent.street, PropertyForRent.postcode, PropertyForRent.city
FROM Staff INNER JOIN PropertyForRent ON Staff.[staffNo] = PropertyForRent.[staffNo]
Where Staff.staffNo = PropertyForRent.staffNo
Order by Staff.staffNo

Also, group the properties together by their responsible person.
Wie kann ich dieses noch in meinem Code integrieren?

-----

Create a view for the clients. The user should enter the maximum amount of rent that he or she is willing to pay, and the query returns a list with the specific details (full address, property type, number of rooms, and monthly rent) of all appropriate properties.

Mein Code:
SELECT PropertyForRent.street, PropertyForRent.postcode, PropertyForRent.city, PropertyForRent.type, PropertyForRent.rooms, PropertyForRent.rent
FROM PropertyForRent
WHERE (((PropertyForRent.rent) Between 0 And [Enter your Maximum of Monthly Rent]));

The user should not be able to change any details in the list.
Hier finde ich den entsprechenden Befehl nicht
VBA-Code habe ich gefunden: Application.SetOption "Standard bei Datensatzsperrung", 0 ??

-------

Create a list of properties with full details, where the rent per room is also indicated (supporting shared renting of apartments).

Mein Code:
PropertyForRent.propertyNo, PropertyForRent.street, PropertyForRent.city, PropertyForRent .postcode, PropertyForRent.type, PropertyForRent.rooms,                                                                                                                                          PropertyForRent.rent,                                                                      PropertyForRent.rent\PropertyForRent.rooms AS [Rent per room], PropertyForRent.staffNo, PropertyForRent.branchNo
FROM PropertyForRent

Hier würde mich gerne wissen wie ich hier PropertyForRent.rent\PropertyForRent.rooms  
die Funktion Round(expression [, numdecimalplaces ] )
verwende.

Wahrscheinlich viele basic Fragen, aber einige Anmerkungen würden mir sehr weiterhelfen.
danke.

gruss
mak
Titel: Re: Gruppierung und Sperren von Datensätzen einer Tabelle über SQL Code
Beitrag von: database am September 27, 2010, 19:05:10
Hallo,

Deutsch ist schon eine wunderschöne Sprache, vor allem für jene, die damit aufgewachsen sind.
Ich hasste es immer, etwas in einer anderen Sprache zu lernen.

Zum ersten Problem:

Ich kann mir eigentlich nur vorstellen, dass hier das einfügen einer Gruppierung gemeint ist - also:

SELECT Distinct Staff.staffNo, PropertyForRent.propertyNo, PropertyForRent.street, PropertyForRent.postcode, PropertyForRent.city
FROM Staff INNER JOIN PropertyForRent ON Staff.[staffNo] = PropertyForRent.[staffNo]
Where Staff.staffNo = PropertyForRent.staffNo
GROUP BY Staff.staffNo, PropertyForRent.propertyNo, ....
Order by Staff.staffNo



Zum 2. Problem
Ich kenne keinen SQL Befehl, der das bewerkstelligen könnte, daher bitte hier nachlesen ...

http://www.fullaccess.de/CONT_EN_d9042481-dcb4-4f0c-a77e-68e183356ffc.aspx (http://www.fullaccess.de/CONT_EN_d9042481-dcb4-4f0c-a77e-68e183356ffc.aspx)

Und Problem Nr. 3

Zitat
Hier würde mich gerne wissen wie ich hier PropertyForRent.rent\PropertyForRent.rooms
die Funktion Round(expression [, numdecimalplaces ] )
verwende.

Nach Berichtigen des Divisionszeichens:  ----> ist kein Backslash sondern Slash!
Um das Ergebnis der Division mit 2 Nachkommastellen darzustellen:

PropertyForRent.propertyNo, PropertyForRent.street, PropertyForRent.city, PropertyForRent .postcode, PropertyForRent.type, PropertyForRent.rooms,                                                                                                        PropertyForRent.rent,  Round(PropertyForRent.rent/PropertyForRent.rooms, 2) AS [Rent per room], PropertyForRent.staffNo, PropertyForRent.branchNo
FROM PropertyForRent

Hoffe das passt so?
;D

Grüße
Peter